LinkedList: A List.......That is Linked - Casady-ComSci-Seminar/Seminar-Notes GitHub Wiki
Introduction to LinkedList:
- In a linked list the elements are all linked together in a linear structure.
- They are linked together with pointers which point from one to the next. The basic structure is described in the image below ⬇️.
We used nodes which were all connected with pointers in order to create our linked lists. They all had a reference or a link to the next node. These nodes also contained a number value.
HeadPtr:
- The head pointer is what is always pointing at the most recent node placed on the end of the stack. No matter what is added to the list, the head pointer will always be pointing at the last thing added.
- If there are no items in the list the head pointer points at NULL instead of a node.
- Head pointers are very useful in iterating through the list.
TailPtr:
- A tail pointer can be added to the linked list as well.
- A tail pointer works similarly to the head pointer in that it is added to an item pushed onto the stack. However, the tail pointer only points at the first thing added onto the list, so that that tail pointer is always at the very back of the list.
- It allows you to add nodes onto the end as opposed to at the beginning.
Why??????:
- We learned how to manipulate pointers and understand the concepts behind them better than we previously did.
- We learned how to traverse through a linked list without just indexing like we would do in a normal list.
- We learned that sometimes the deconstructor actually has to do something(clear the list).
- I learned that sometimes fixing stuff with a minus 1 or 2 doesn't really do anything but make trying to fix code way more confusing.