Assignment 6


Start with C++ code on p. 732 and write functions to accomplish the following tasks:

1.     Write a function int findMax(IntNodePtr p) that returns the largest integer stored in the linked list pointed to by p.

2.     Write a function void printOdd(IntNodePtr p) that prints out all integers that appear in odd positions, i.e., the first integer, the third integer, the fifth integer, and so on.

3.     Write a function int findLen(IntNodePtr p) that returns the length of a linked list.

4.     Write a function void divideList(IntNodePtr p, IntNodePtr& first, IntNodePtr& second) that evenly breaks up a list p into the first half and second half.

5.     Write a main program to read in some integers from cin and insert them one by one into a linked list in reverse order, that is, the integer read in the first appears at the end of the list. Test other functions using this list in main( ).


To prepare for the final exam, you also need to study those tasks (such as search and delete) covered in the textbook.