Final Exam Master Challenge
Coverage: Modules 7-13 (Transform-and-Conquer, Space-Time Trade-offs, Dynamic Programming, Greedy, Limitations, Coping).
Part 1: 70 Multiple Choice Questions. Part 2: 10 Concept Essay Questions.
Part 1: The Gauntlet (MCQ)
Part 2: The Deep Dive (Concepts)
1. Heaps vs. BSTs
Mod 7Explain the structural and ordering differences between a Heap and a Binary Search Tree (BST). Why is a Heap generally preferred for implementing a Priority Queue?
Priority Queue: Heaps allow accessing the Min/Max in O(1) and removing it in O(log n). A BST takes O(log n) to find min/max (if balanced) but has higher overhead to maintain balance (AVL/Red-Black). Heaps can also be implemented efficiently as arrays.
2. Open vs. Closed Hashing
Mod 9Compare Open Hashing (Separate Chaining) and Closed Hashing (Open Addressing). Under what conditions does Closed Hashing degrade significantly?
Closed Hashing: Keys stored inside the table slots. Requires Load Factor < 1.
Degradation: Closed hashing degrades rapidly as the Load Factor approaches 1 (table gets full) due to "Clustering" (long sequences of occupied cells), turning search/insert into O(n).
3. Dynamic Programming vs. Divide & Conquer
Mod 10Both techniques split problems into subproblems. What is the fundamental difference that dictates when to use DP instead of D&C? Give an example where D&C fails but DP works.
Example: Calculating Fibonacci numbers. D&C naively recalculates F(n-2) multiple times, leading to exponential time. DP stores the result of F(n-2) once and reuses it, achieving linear time.
4. The Principle of Optimality
Mod 10Define the Principle of Optimality. Explain why the Longest Path problem does not satisfy this principle, whereas Shortest Path does.
Shortest Path: If A->B->C is shortest, then A->B must be the shortest path to B.
Longest Path: The longest simple path from A to C might not use the longest simple path from A to B because using the longest A->B path might use vertices needed for the B->C leg (causing a cycle).
5. Greedy vs. DP in Knapsack
Mod 11Why does the Greedy strategy (sorting by value/weight) work for the Fractional Knapsack problem but fail for the 0/1 Knapsack problem?
6. Dijkstra and Negative Weights
Mod 11Explain precisely why Dijkstra's algorithm fails if the graph contains negative edge weights. What algorithm should be used instead?
7. P vs NP
Mod 12Define the classes P and NP. Clarify the common misconception that "NP stands for Not Polynomial".
NP: Nondeterministic Polynomial. Problems where a solution can be verified in Polynomial Time.
Misconception: It does NOT mean "Not Polynomial". P is a subset of NP.
8. The Halting Problem
Mod 12What is the Halting Problem and what does it prove about the limitations of algorithms?
9. Backtracking vs. Branch-and-Bound
Mod 13Distinguish between Backtracking and Branch-and-Bound. Which one is used for N-Queens and which for Knapsack? Why?
Branch-and-Bound: Uses a numerical bound (cost function) to prune branches. Used for optimization problems (finding best solution) like Knapsack or TSP.
10. Approximation Accuracy
Mod 13What is the Performance Ratio ($\rho$) of an approximation algorithm? For TSP Nearest Neighbor, is this ratio bounded?