LinkedList Flashcards
Is a Linked List Random or Sequential Access?
Sequential
Is a LinkedList a linear data structure?
Yes
Each element is created as a separate…
Object
What is each individual element called?
Node
A Node is made up of two parts. What are they?
- The data (could be complex objects)
2. The reference (or pointer) the the next Node in the List.
What is a real-world analogy for a ACCESSING an element in a LinkedList?
A tape measure. To get to inch 72 you first have to traverse inches 1 through 71.
How do we know when we have reached the end of a LinkedList?
The reference to the next Node will be null.
What is the term for the first Node in a LinkedList?
The HEAD Node.
What is the term for the last Node in a LinkedList?
The TAIL Node.
Data can flow in and out of …. point of a LinkedList.
Any
What are the three places in a LinkedList that we can ADD or REMOVE data?
HEAD, MIDDLE, TAIL.
How do we ADD a Node to the Head of LinkedList?
We make the new head Node point to the old head Node and update what Node we consider to be the head node in our implementation.
How do we DELETE a Node from the Head of LinkedList?
We make the 2nd Node in the list our new head Node and make the old head Node point to null.
How do we ADD a Node somewhere in the middle of a LinkedList? (2 steps)
- Make the pointer of the new Node point to the Node after the location we want to insert at.
- Set the Node before the location we want to insert at to point towards the new Node.
How do we REMOVE a Node somewhere in the middle of a LinkedList? (1 step)
Make the pointer of the Node previous to the one we’re removing, to now point to the Node after the one we’re removing.