In week
8 we learnt about the data structure linked lists. Just like trees, linked lists
are made up of nodes which point to other nodes but in linked lists each node can only point to
one other node, this node is called the next node. The first
and last nodes in a linked list are kept track of in the linked list class and
are named the front and back nodes or sometimes the head and tail, as seen
in the image below.
When I first tackled the linked list lab I
found it a little confusing and I was unable to get the first function in the
lab to work as intended. Since this type of mutable and iterative data
structure was new to me I knew that before trying any of the functions I had to
play around with the class and draw lots of picture until I felt that I had a
firm understanding of linked lists. Sure enough after I had done this I was
able to complete all of the functions/methods without problem.
I'm curious as to what kind of initial problems you had with linked lists and how you figured it out. I say this cause I also encountered problems when I initially treated it like I would a normal list. My problem was that I wasn't moving the other nodes to accommodate the hole I would make when I removed another node.
ReplyDeleteYes I was encountering a similar problem, I was not changing the next node to the correct node.
ReplyDelete