Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
L
and t
, both of type
Node*
, with the values depicted in the figure below:
|
The definition of struct Node is given above too. Write statement(s) that perform the following. Note: each problem is independent, meaning that changes in one part are not carried forward into the next part.
|
|
|
| Draw a picture that depicts the code (like the picture in problem 1): |
Hint: Store the numbers in your linked list in reverse order
by calling add2front
repeatedly (why will the list have reverse order?) as you read each
number in.
Example runs:
~/$ ./hw 7 2 8 -1 7 |
Hint 2: Don't hesitate to draw a picture of some small examples by
executing add2front() one by one. In particular, make sure
to understand that the picture in problem 1 represents the list shown on the left.
|
~/$ ./hw 1 2 3 4 5 6 7 8 9 -1 7 ~/$ ./hw 4 8 2 7 4 9 -1 7
Submit: ~/bin/submit -c=IC210 -p=hw36 hw.cpp
Turn In the codeprint of your source code.