linked-list

    0热度

    1回答

    我们可以使用一个队列并将所有节点标记为BFS。如果图形存储在邻接矩阵中,这很容易,我们可以很容易地得到有多少个节点并创建一个标记数组。 如果我有这样的TreeNode定义,该怎么办? (给予这样的定义,我不知道有多少节点都是在树中。) # Definition for a binary tree node class TreeNode: def __init__(self, x):

    -4热度

    1回答

    我是C++的初学者。我试图按队列顺序(FIFO)写一个动态分配的链表。该程序可以编译并运行。但我无法打印任何东西。所以我不知道链接或打印输出逻辑中是否存在问题。请帮忙。 #include <iostream> using std::cout; using std::cin; using std::endl; using std::ios; #include <iomanip> usin

    0热度

    1回答

    我想创建2d链接列表。当我尝试访问其元素时,会导致分段错误。 下面是代码 struct Node{ char *data; int count; struct Pair *p; struct Node *next; }; struct Pair{ char *data; int count; struct Pair *ne

    0热度

    1回答

    这是一个结构,我给了一个返回指向新的空队列的指针的队列。我知道队列 - >后端指向队列后面的节点,队列 - >后 - >下一个指向队列前端的节点。我如何称呼队列的前端?每当我使用queue-> rear-> next时,我都会遇到运行时错误。 intqueue_t *intqueue_construct(void) { intqueue_t *queue = malloc(sizeof(int

    0热度

    1回答

    为了实现使用循环链表的队列集合,我给了这些结构声明。 typedef struct intnode { int value; struct intnode *next; } intnode_t; typedef struct { intnode_t *rear; // Points to the node at the tail of the // queue's l

    0热度

    1回答

    我只是想知道,在一个链表是什么两者之间的区别: node1 = node2 和 node1->next = node2 第一行让我有点困惑。

    0热度

    1回答

    我使用了一个函数来将新节点插入到我的单链表中,但是当我插入后打印出节点内的所有值时,我只能得到第一节点: // Make list createList(head, 17); // Insert to list for (int x = 9; x > 0; x /= 3) { if (!insertToList(head, x)) { fprintf(st

    0热度

    3回答

    我试图做一个链接列表,其中每个节点存储一个字符串,但我有一个问题,其中每个节点最终在每个节点中存储相同的确切字符串单节点。在main()的结尾处,我打印出存储在每个节点中的单词,它总是重复为整个列表输入的最后一个字符串。 我没有任何线索发生了什么事情,因为如果我将它制作成一串字符,它就可以很好地工作,每个字符都存储在正确的节点中。 #include <stdio.h> #include <str

    0热度

    1回答

    我想实现链接列表的复制构造函数。我已经写了返回的将是用于拷贝构造函数和重载赋值运算符列表的复制方法: template<class T> SinglyList<T> SinglyList<T>::copy(Node *u) { SinglyList<T> newList; Node *current = u; if (current->next==NULL)

    1热度

    1回答

    下面是一个示例程序是什么我谈论: #include <iostream> #include <list> using namespace std; class Thing { public: virtual void jump() { cout << "Called from Thing class" << endl; } }; class Car: publ