Unit V: Advanced Tree & Graph Algorithms, NP Problems, Approximation, etc.
1. Advanced Tree Algorithms
AVL Tree:
- Self-balancing BST. Balance Factor: -1, 0, 1.
- Uses rotations to maintain balance.
- O(log n) operations.
Red-Black Tree:
- BST with Red/Black colors.
- Rules to maintain balance.
- O(log n) operations.
2. Advanced Graph Algorithms
Topological Sort:
- Linear ordering of DAG.
- O(V + E).
SCC:
- All nodes mutually reachable.
- Kosaraju/Tarjan algorithms.
Articulation Point & Bridges:
- Nodes/edges whose removal increases components.
3. NP-Hard and NP-Complete
P: Solvable in polynomial time.
NP: Verifiable in polynomial time.
NP-Hard: As hard as NP problems.
NP-Complete: Both NP & NP-Hard.
Unit V: Advanced Tree & Graph Algorithms, NP Problems, Approximation, etc.
Examples: SAT, TSP, Knapsack, Graph Coloring.
4. Approximation Algorithms
Used for NP-Hard problems.
- Approximation ratio = approx/optimal.
Examples:
- Vertex Cover: Ratio <= 2
- TSP (metric): Ratio <= 2
- Knapsack: FPTAS available.
5. Data Stream Algorithms
Used for massive data with limited memory.
- Count-Min Sketch: frequency approximation.
- Bloom Filter: membership testing.
- Reservoir Sampling: random sampling.
Applications: Logs, networks, sensors.
6. Parallel Algorithms
Goal: faster solutions using multiple processors.
Models: PRAM (EREW, CREW, CRCW).
Efficiency = speedup / processors.
Examples: Parallel Prefix Sum in O(log n) time.
Techniques: divide-conquer, pipelining.