| Chapter 9
# 15, 16, 17, 22 pages 495 to 497 15. Assume that p, q, r, and nextNode are pointers to character nodes. Initially, the nodes for p and q are dynamically allocated with values X and A, respectively. The three upcoming statements build a portion of linked list. After each statement, describe the resulting chain of nodes. (a) r = new node<char> ('M');16. Use the following linked list of integer nodes for each part:
i.e.
Assume the declaration node<int> *front, *p, *newNode, *nextNode;(a) Consider the following statement, which addes a new node to the list: front = new node<int> (30, front);The value of the first node in the list is ________ The value of the second node in the list is ________ The value of the third node in the list is ________ (b) Assume that p points at the node with value 10. Execute the following statemrnts: nextNode = p->next;The integer value of node p after the statements is ______________ The value of the node that is deleted from the list is ______________ (c) The following loop scans the list: p = front;Will the cout statement execute properly? (d) Modify the code in part (c) so that it outputs the value 80.
int t;What are the data values for each node in the resulting list? 17. Apply the following function to the lists in parts (a) and (b), and display the new list: template <typename T>(a) Assume that front points at the integer list front -> 2 -> 8 -> 5 -> 7 -> 2 -> 9 ->25(b) Assume that front points at the character list containing the elements "template." 22. Fill in the statements to build the following doubly linked list:
dnode<int> *header = ________, *curr, *newNode; |