(Note: Instead of 'head' we simply called it 'front', and the last node was called 'back'.)
When we began to implement methods, things became a little complicated. We first created a class called LLNode, which represented each node of a linked list. Each LLNode had attributes of the current value and the next value. We then created a LinkedList class, which had the methods of mutation. The algorithm and tracing of these methods was pretty difficult. The professor suggested that we draw pictures of the linked list to visualize the mutation occurring. This really helped me understand what each method was doing. Also, each method did not involve recursion, which is what we have been using with our tree methods. Instead, we were simply iterating over the linked list, much like we do with an ordinary list.

No comments:
Post a Comment