Chapter 17: Problem 15
After creating a linked list’s head pointer, you should make sure it points to __________ before using it in any operations.
Chapter 17: Problem 15
After creating a linked list’s head pointer, you should make sure it points to __________ before using it in any operations.
All the tools & learning materials you need for study success - in one app.
Get started for free\(\mathrm{T} \quad \mathrm{F} \quad\) When the head pointer points to nullptr, it signifies an empty list.
What type of linked list is the STL list container?
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; } }
Find as many mistakes as you can. void NumberList::appendNode(double num) { ListNode *newNode, *nodePtr; // Allocate a new node & store num newNode = new listNode; newNode->value = num; // If there are no nodes in the list // make newNode the first node. if (!head) head = newNode; else // Otherwise, insert newNode. { // Find the last node in the list. while (nodePtr->next) nodePtr = nodePtr->next; // Insert newNode as the last node. nodePtr->next = newNode; } }
What are some of the advantages that linked lists have over arrays?
What do you think about this solution?
We value your feedback to improve our textbook solutions.