CS12, Lab 8
Week of May 20 – 24
Topics
·
Linked Lists
·
Recursion
·
assert
To do
Copy the
(partially complete) program llist.cpp. The program implements a linked list. Currently, it has functions for
inserting numbers into the list, three different functions for printing the
list, and shells for two different search methods
Complete the
search functions as specified. One
should perform the search iteratively (with a loop). The other should perform the search recursively.
Note the use of
assert in the print functions. As
you write the search functions, think what should be true of the pointer at key
points in the function, and add assert statements to verify that your
assumptions are correct.
Extra
Credit (5 points)
Write an
iterative printReverse function.
Because the arrows on the list go in one direction, you will need to go
back to the head and run through the list for every node you print. This will require an auxiliary pointer
to keep track of the last node you printed.