
Goal: Teach beginners everything about Linked Lists to confidently solve common data structure and algorithm interview problems.
| Concept | Description | Importance |
|---|---|---|
| Node | A container for data (strings, numbers, booleans, objects). Conceptually visualized as a circle. | Core Concept |
| Link | A pointer from one node to the next node in the sequence (e.g., A's next is B). | Core Concept |
| Linked List | A collection of many nodes linked together in a sequence. | Core Concept |
| Last Node | The final node in the list. Its next pointer is set to null or None, signifying the end. | High |
| Head | The very first node of the linked list. | High |
| Tail | The very last node of the linked list. | High |
| Ordered Data Structure | A key characteristic allowing sequential traversal by following next pointers from head to tail. | High |
| Node Position | Positions are typically zero-indexed (Head is at index 0). | Medium |
| Feature | Array | Linked List | Importance |
|---|---|---|---|
| Memory Storage | Must be stored contiguously (blocks right next to each other in memory). | Non-contiguous (nodes can exist anywhere in memory, linked by pointers). | Critical Distinction |
| Insertion at Index | Requires shifting all subsequent elements to make space. | Requires only adjusting pointers (specifically two pointers). | Critical Distinction |
| Insertion Time Complexity | $O(N)$ (Worst case: inserting at index 0 requires shifting all $N$ elements). | $O(1)$ (Constant time, assuming you already have the reference to the insertion point). | Critical Distinction |
current variable (pointer), starting at the head. In a loop, set current = current.next until current is null/None.Iterative Solution
while current is not None: loop.current.val and update current to current.next.Recursive Solution
head is None, return (handles end of list or empty list).head.val, then recursively call the function on head.next.Problem: Given the head, return a list (array) containing all node values in the correct order.
Complexity Analysis
Iterative Solution
while loop to traverse.current.val to the values list.current = current.next.Recursive Solution (Using Helper Function)
values list without creating new list copies in every stack frame.values list.fill_values(head, values).head is None, return.head.val to values, then call fill_values(head.next, values).