| Exercise | Initial Setup | Final Configuration |
| 1 |
Use a single assignment statement to make the pointer p point to the Node with info '2', thus creating a memory leak.
| Ready to solve it? |
 |
|
 |
 |
| 2 |
Redo exercise 1 but, this time, your assignment statement must refer to both pointers p and q.
| Ready to solve it? |
 |
|
 |
 |
| 3 |
Use a single assignment statement to make the pointer q point to the Node with info '1'.
| Ready to solve it? |
 |
|
 |
 |
| 4 |
Use a single assignment statement to make the pointer r point to the Node with info '2'.
| Ready to solve it? |
 |
|
 |
 |
| 5 |
Use a single assignment statement to set the info of the Node pointed to by p equal to the info of the Node pointed to by r (you must access this info through r; do not refer to the character '3' directly).
| Ready to solve it? |
 |
|
 |
 |
| 6 |
Redo exercise 5 by referring only to pointer p (not to pointer r). Again, you may not refer to the character '3' directly .
| Ready to solve it? |
 |
|
 |
 |
| 7 |
Write a single assignment statement to transform the linked list headed by p into a circular linked list. Your assignment statement must refer to both pointers p and r.
| Ready to solve it? |
 |
|
 |
 |
| 8 |
Redo exercise 7 but, this time, your assignment statement must refer to both pointers p and q.
| Ready to solve it? |
 |
|
 |
 |
| 9 |
Redo exercise 7 but, this time, your assignment statement must refer only to pointer p.
| Ready to solve it? |
 |
|
 |
 |
| 10 |
Write a single assignment statement to remove the Node with info 'B' from the linked list headed by p, thus creating a memory leak. Your assignment statement must refer to both pointers p and q.
| Ready to solve it? |
 |
|
 |
 |
| 11 |
Write a single assignment statement to remove the Node with info 'B' from the linked list headed by p, thus creating a memory leak.
| Ready to solve it? |
 |
|
 |
 |
| 12 |
Write a while loop to make q point successively to each Node in the linked list headed by p. q must end up pointing to the last Node in the list.
| Ready to solve it? |
 |
|
 |
 |
| 13 |
Write a while loop to make q point successively to each Node in the linked list headed by p until q points to the first Node with info (lowercase) 'c'.
| Ready to solve it? |
 |
|
 |
 |
| 14 |
Use four assignment statements, each referring to pointer p, to create a linked list headed by p and containing 4 Nodes with info 'A', 'B', 'C', and 'D', in this order.
| Ready to solve it? |
 |
|
 |
 |
| 15 |
Create a new Node with info 'A' and insert it at the beginning of the list headed by p.
| Ready to solve it? |
 |
|
 |
 |
| 16 |
Create a new Node with info 'D' and insert it at the end of the list headed by p.
| Ready to solve it? |
 |
|
 |
 |
| 17 |
Remove the Node at the beginning of the list headed by p and insert it at the end of the same list (note that one solution uses the pointer variable q, while another, more interesting solution does not).
| Ready to solve it? |
 |
|
 |
 |
| 18 |
Merge the two lists headed by p and q into a single list headed by p in which the Nodes are sorted in alphabetical order.
| Ready to solve it? |
 |
|
 |
 |
| 19 |
Using only the three existing pointer variables p, q, and r, reverse
the order of the Nodes in the list headed by p.
| Ready to solve it? |
 |
|
 |
 |
| 20 |
Delete all the nodes in the list headed by p, making sure to avoid memory leaks and dangling pointers.
| Ready to solve it? |
 |
|
 |
 |