Chapter 17: Problem 19
In a(n) __________ list, the last node has a pointer to the first node.
Chapter 17: Problem 19
In a(n) __________ list, the last node has a pointer to the first node.
All the tools & learning materials you need for study success - in one app.
Get started for freeWhat does "traversing the list" mean?
After creating a linked list’s head pointer, you should make sure it points to __________ before using it in any operations.
Consider the following code: struct ListNode { int value; struct ListNode *next; }; ListNode *head; // List head pointer Assume that a linked list has been created and head points to the first node. Write code that traverses the list displaying the contents of each node’s value member.
How is the end of a linked list usually signified?
Find as many mistakes as you can. void NumberList::deleteNode(double num) { ListNode *nodePtr, *previousNode; // If the list is empty, do nothing. if (!head) return; // Determine if the first node is the one. if (head->value == num) delete head; else { // Initialize nodePtr to head of list. nodePtr = head; // Skip all nodes whose value member is // not equal to num. while (nodePtr->value != num) { previousNode = nodePtr; nodePtr = nodePtr->next; } // Link the previous node to the node after // nodePtr, then delete nodePtr. previousNode->next = nodePtr->next; delete nodePtr; } }
What do you think about this solution?
We value your feedback to improve our textbook solutions.