Exam Traps, Recurrence Matching, MSTs, and Rapid-Fire MCQs
Revision Module — Let’s see if you actually understand everything.
This module is not about learning new concepts. It is about pattern recognition, exam traps, and response speed. If you can spot the trap, you save minutes on the exam.
An MST exists only in connected, undirected graphs.
Core Properties:
The Big Two Algorithms:
Exams love to test your array mathematics for heaps. Do not memorize just one formula!
If the question specifies 1-based indexing (Root is at index 1):
Parent(i) = ⌊i/2⌋
Left(i) = 2i
Right(i) = 2i + 1
If the question specifies 0-based indexing (Root is at index 0):
Parent(i) = ⌊(i - 1) / 2⌋
Left(i) = 2i + 1
Right(i) = 2i + 2
Crucial Trap: You CANNOT compute the total "Heap Size" just by knowing the index
iof a single node. An index only tells you position/geography, not how many elements actually exist in the background array!
You must recognize recurrence relations instantly without applying the full Master Theorem every time:
| Algorithm | Recurrence | Complexity | Why? |
|---|---|---|---|
| Binary Search | T(n) = T(n/2) + c | O(log n) | Divide search space in half (1 branch). |
| Merge Sort | T(n) = 2T(n/2) + O(n) | O(n log n) | Divide in half (2 branches) + linear scan to merge. |
| Quick Sort (Worst) | T(n) = T(n-1) + O(n) | O(n²) | Pivot is extreme, dividing array into sizes 0 and n-1. |
| Linear Search | T(n) = T(n-1) + c | O(n) | Check one item, recursively check the rest. |
If a question asks for the "Shortest path in an UNWEIGHTED graph":
Mindset: "Minimum distance" + "Unweighted graph" = Brain screams BFS.
A BST's efficiency is entirely controlled by its height (h).
| Operation | Time Complexity | Reason |
|---|---|---|
| Successor | O(h) | May need to walk down the tree. |
| Minimum | O(h) | Walk as far left as possible. |
| Maximum | O(h) | Walk as far right as possible. |
| Insert / Delete | O(h) | Walk down to the correct insertion spot. |
| Inorder Traversal | O(n) | Must visit every single node! |
Worst Case Trap: What if the tree is completely skewed (e.g. elements inserted in sorted order)?
Time Complexity Ordering:
You must know the order of complexities instantly from fastest to slowest:
O(1) < O(log n) < O(n) < O(n log n) < O(n²)
Hashing vs Search:
n). Assumes a good hash function and low collisions!Quick Sort vs Randomized Quick Sort:
If you see the algorithm/problem, you must instantly know the underlying Data Structure:
| Algorithm / Problem | Corresponding Data Structure |
|---|---|
| BFS | Queue |
| DFS | Stack (Or Recursion Call Stack) |
| Dijkstra / Prim | Priority Queue / Min-Heap |
| Heap Sort | Priority Queue / Max-Heap |
| Secondary Storage (Hard Disk) | B-Trees (Optimized for large block reads) |
Normal trees have a lot of wasted NULL pointers at the leaves.
Threaded Binary Trees utilize these naturally empty pointers to point to their inorder predecessor or successor.
Data structures are not isolated islands. They form a deeply connected ecosystem. Do not memorize facts—understand the connections:
Proceed to the Practice Quiz to test your response speed against actual exam traps.
Test your understanding with step-by-step solutions
15 questions · 90s per question
Each question has a 90-second time limit. Unanswered questions will be auto-submitted when time runs out.