1. Introduction to Linked List
- Linked List = A linear data structure where elements (nodes) are linked using pointers instead of contiguous memory.
- Each node contains:
- Data – Actual value stored.
- Pointer/Next – Address of next node.
- Data – Actual value stored.
- Advantage: Dynamic memory allocation, easy insertion/deletion.
2. Linked List as an Abstract Data Type (ADT)
- ADT defines logical operations without specifying implementation.
- Basic Operations:
- Insert(node, position) – Add node at specific position.
- Delete(position) – Remove node from a given position.
- Traverse() – Access nodes sequentially.
- Search(element) – Find a node containing the element.
- Update(position, element) – Modify node’s data.
- Insert(node, position) – Add node at specific position.
3. Types of Linked Lists
- Singly Linked List
- Each node points to the next node.
- Traversal is one-way only.
- Each node points to the next node.
- Doubly Linked List
- Each node has next and previous pointers.
- Supports two-way traversal.
- Easier insertion/deletion at both ends.
- Each node has next and previous pointers.
- Circular Linked List
- Last node points back to the first node.
- Can be singly or doubly linked.
- Last node points back to the first node.
4. Operations on Linked List
- Insertion
- At beginning: New node becomes head.
- At end: New node added after last node.
- After/before a node: Use pointer to adjust links.
- At beginning: New node becomes head.
- Deletion
- At beginning: Head moves to next node.
- At end: Second last node’s next pointer = NULL.
- Specific node: Adjust previous node’s pointer.
- At beginning: Head moves to next node.
- Traversal
- Start from head → follow next pointers → reach NULL.
- Start from head → follow next pointers → reach NULL.
5. Linked Stacks and Queues
- Stack using Linked List: Top = head node, push/pop at head.
- Queue using Linked List: Front = head, Rear = tail, enqueue at tail, dequeue at head.
6. Advantages of Linked Lists
- Dynamic size – Grows/shrinks at runtime.
- Efficient insertion/deletion – No shifting like arrays.
- Flexible memory usage – No wasted space.
- Supports complex structures – Graphs, adjacency lists, etc.
7. Applications
- Implement stacks and queues dynamically.
- Dynamic memory allocation in OS (free lists).
- Represent polynomial expressions, sparse matrices.
- Undo/redo operations in software applications.
Key Takeaways – Unit 5
- Linked list = dynamic linear structure using pointers.
- Types: Singly, Doubly, Circular – each has unique traversal and insertion/deletion capabilities.
- Supports efficient memory usage and dynamic operations.
- Forms the basis for dynamic stacks, queues, and complex data structures.