Name:
15-200 Homework #2
One a separate piece of paper, please draw a linked list
after each of the following steps involving linked list operations. Please use
a notation such as the one we used in class, or the one in your textbook. Please show each change to each reference,
including head and tail.
As a reminder, a node consists of two member references:
“data” and “next”. You can use arrows, labels, or any other reasonable way of
associating a reference with the object it names.
- Begin
with the list above (redraw it).
- Add
the String “A” into the linked list in between the smile and the moon.
Please show the creation the new node, and then each of the adjustments to
the references.
- Add
the String “B” into the
linked list in between the A and the moon. Please show the creation
the new node, and then each of the adjustments to the references.
- Add
the String “C” into the linked list in between the moon and the heart.
Please show the creation the new node, and then each of the adjustments to
the references.
- Delete
the moon from the linked list. Please remember that this will involve
changes to the node before the one that holds the moon.
- Delete
the smile from the linked list. Please remember that this is the first element in the list.