Data Structures - Quick Revision Notes
STACK (LIFO)
- Operations:
- push(x): Insert at top
- pop(): Remove from top
- peek(): View top element
- Applications:
- Expression evaluation
- Undo features
- Function call stack
- Array-based: Fixed size, easy to implement
- Linked List-based: Dynamic size
QUEUE (FIFO)
- Operations:
- enqueue(x): Add at rear
- dequeue(): Remove from front
- Types:
- Simple Queue
- Circular Queue
- Double-ended Queue (Deque)
- Applications:
- Job scheduling
- Print queue
- Buffer handling
LINKED LIST
- Types:
Data Structures - Quick Revision Notes
- Singly Linked List (next)
- Doubly Linked List (prev & next)
- Circular Linked List (last node connects to first)
- Operations:
- Insert (start, middle, end)
- Delete (by position/data)
- Traverse
- Advantages: Dynamic memory
- Disadvantages: Slow access (no index)
TREE (Binary Search Tree)
- Binary Tree: Max 2 children
- BST (Binary Search Tree):
- Left < Root < Right
- Traversals:
- Inorder: Left, Root, Right (gives sorted output in BST)
- Preorder: Root, Left, Right
- Postorder: Left, Right, Root
SEARCHING TECHNIQUES
- Linear Search:
- Checks each element one by one
- Time Complexity: O(n)
- Binary Search:
- Works only on sorted arrays
- Divide and conquer
- Time Complexity: O(log n)