GATE Previous Year Questions — Uninformed Search
Prerequisites
- BFS, DFS, IDDFS, UCS — Algorithm mechanics and properties
- Complexity Analysis — Time and space formulas for each strategy
- Comparison — Completeness, optimality, and trade-offs
🎯 Learning Objectives
- Practice with authentic GATE-style problems on uninformed search
- Master the step-by-step trace technique for exam questions
- Identify common traps and distractors in search strategy questions
- Build speed and accuracy for the 2-mark MCQ and NAT formats
This page contains 10 carefully curated GATE-style questions that test the most frequently examined concepts in uninformed search. Each question includes a detailed solution walkthrough and a key takeaway for exam preparation.
Question 1 — BFS Node Expansion Count
Consider a search tree with branching factor b = 3 and the goal node at depth d = 3. BFS expands nodes level by level. Assuming that the goal is the last node generated at depth 3, how many nodes does BFS expand (i.e., remove from the frontier and generate successors for) before finding the goal?
Options:
- 13
- 39
- 40
- 121
Key insight: BFS tests for the goal when a node is generated (added to the frontier), not when it is expanded. However, the question asks how many nodes are expanded.
- Depth 0: Expand root → 1 node expanded, generates 3 children.
- Depth 1: Expand all 3 nodes → 3 nodes expanded, generates 9 children.
- Depth 2: Expand all 9 nodes → 9 nodes expanded, generates 27 children at depth 3.
Total nodes expanded = 1 + 3 + 9 = 13. The goal is the last node at depth 3, but with early goal test, BFS identifies it upon generation without expanding it.
Answer: A. 13
Key Takeaway: BFS with early goal test expands all nodes at depths 0 through d−1 = (bd − 1) / (b − 1). With b=3, d=3: (27−1)/2 = 13.
Question 2 — DFS Traversal Order
Consider the following tree where children are expanded left-to-right:
A
/ | \
B C D
/\ /\
E F G H
|
I
What is the order in which nodes are visited (expanded) by DFS?
Options:
- A, B, E, F, I, C, D, G, H
- A, B, C, D, E, F, G, H, I
- A, B, E, F, I, D, G, H, C
- A, D, H, G, C, B, F, I, E
DFS uses a LIFO stack. With left-to-right expansion:
- Expand A → push D, C, B (B on top).
- Expand B → push F, E (E on top).
- Expand E → no children. Pop next: F.
- Expand F → push I.
- Expand I → no children. Pop next: C.
- Expand C → no children. Pop next: D.
- Expand D → push H, G (G on top).
- Expand G → no children. Pop next: H.
- Expand H → done.
Order: A, B, E, F, I, C, D, G, H → Answer: A
Key Takeaway: When tracing DFS, push children in reverse order onto the stack so the leftmost child is on top. Alternatively, think recursively: always go to the deepest leftmost unexplored node first.
Question 3 — BFS vs DFS Space Complexity (NAT)
A search tree has branching factor b = 4 and the solution is at depth d = 5. The maximum depth of the tree is m = 10.
What is the ratio of BFS frontier size to DFS frontier size at their respective worst cases? Express as an integer (round to the nearest whole number).
Use: BFS space = O(bd), DFS space = O(b · m).
BFS worst-case frontier: bd = 45 = 1024.
DFS worst-case frontier: b · m = 4 × 10 = 40.
Ratio = 1024 / 40 = 25.6 ≈ 26.
Answer: 26
Key Takeaway: This dramatic difference is why DFS (and IDDFS) are preferred when memory is the bottleneck. BFS space grows exponentially with depth, while DFS grows only linearly.
Question 4 — IDDFS Total Nodes Generated
Iterative Deepening DFS is run on a tree with branching factor b = 2. The goal is at depth d = 4. How many total nodes are generated across all iterations (depth limits 0, 1, 2, 3, 4)? Assume the goal is found at the last node of depth 4.
Hint: Nodes at depth k in a uniform tree = bk. IDDFS with limit L generates nodes at depths 0, 1, …, L.
IDDFS runs DLS for limits 0, 1, 2, 3, 4. Each DLS(limit=L) generates all nodes at depths 0 through L.
Nodes generated in a complete tree at depth k with b=2: 2k.
Total nodes per DLS iteration (sum of all levels 0 to L) = 20 + 21 + … + 2L = 2L+1 − 1.
| Limit L | Nodes generated |
|---|---|
| 0 | 21 − 1 = 1 |
| 1 | 22 − 1 = 3 |
| 2 | 23 − 1 = 7 |
| 3 | 24 − 1 = 15 |
| 4 | 25 − 1 = 31 |
Total = 1 + 3 + 7 + 15 + 31 = 57
Answer: 57
Key Takeaway: The overhead of IDDFS is modest. Compare with a single BFS run generating 25 − 1 = 31 nodes. IDDFS generates 57/31 ≈ 1.84× as many — close to the theoretical overhead of b/(b−1) = 2 for b=2. For b=10, overhead drops to just ~11%.
Question 5 — Uniform Cost Search Path
Consider the following weighted graph. UCS starts at node S and the goal is G.
S --1-- A --5-- G
| ^
3 |
| 2
B ------4----- C
Edges: S→A (cost 1), A→G (cost 5), S→B (cost 3), B→C (cost 4), C→G (cost 2).
What path does UCS find and what is its cost?
- S → A → G, cost 6
- S → B → C → G, cost 9
- S → A → G, cost 5
- S → B → G, cost 7
UCS uses a priority queue ordered by path cost g(n).
- Init: Frontier = {S: 0}.
- Expand S (cost 0): Add A (cost 1) and B (cost 3). Frontier = {A:1, B:3}.
- Expand A (cost 1): Add G (cost 1+5=6). Frontier = {B:3, G:6}.
- Expand B (cost 3): Add C (cost 3+4=7). Frontier = {G:6, C:7}.
- Expand G (cost 6): Goal found!
Path: S → A → G, cost = 6.
Note: The alternative path S → B → C → G has cost 3+4+2 = 9, which is more expensive.
Answer: A. S → A → G, cost 6
Key Takeaway: UCS always expands the node with the lowest path cost first, guaranteeing optimality. Even though S→B looks cheaper initially (cost 3 vs. 1+5), UCS evaluates total path cost, not just the first step.
Question 6 — Completeness of Search Strategies
Which of the following uninformed search strategies is NOT complete even in a finite state space?
- Breadth-First Search
- Uniform Cost Search (with ε > 0 step costs)
- Depth-First Search (tree search, no cycle detection)
- Iterative Deepening DFS
DFS with tree search and no cycle detection can get stuck in an infinite loop, even in a finite state space, if there are repeated states (e.g., A→B→A→B…). This makes it incomplete.
- BFS: Complete (finite b) ✅
- UCS: Complete (if step costs ≥ ε > 0) ✅
- DFS (tree search): Not complete (infinite loops) ❌
- IDDFS: Complete (same as BFS guarantee) ✅
Answer: C. Depth-First Search
Key Takeaway: DFS is incomplete in two scenarios: (1) infinite-depth paths, (2) loops without cycle detection. GATE often tests whether DFS with graph search (explored set) becomes complete — it does, for finite state spaces.
Question 7 — IDDFS Space Complexity
What is the space complexity of Iterative Deepening DFS?
- O(bd)
- O(b · d)
- O(b · m)
- O(d)
IDDFS performs repeated DFS calls with increasing depth limits. At any given iteration with limit L, DFS stores one path from root to a leaf, plus the siblings at each level.
For the final iteration (L = d), the space is O(b · d) — at each of the d levels on the current path, we store up to b−1 siblings ≈ O(b) nodes.
Previous iterations use less space (smaller depth limits), so the overall space complexity is determined by the last iteration: O(b · d).
Answer: B. O(b · d)
Key Takeaway: This is the key advantage of IDDFS — it achieves BFS-level completeness and optimality (for unit costs) while using DFS-level linear space. Note: O(b·d) not O(b·m), because IDDFS never descends deeper than the current limit, and the solution is at depth d.
Question 8 — UCS Optimality Condition
Uniform Cost Search is guaranteed to find the optimal solution under which condition?
- All edge costs are equal to 1
- All edge costs are non-negative
- Every edge cost is strictly greater than some positive constant ε
- The branching factor is finite
UCS requires that every step cost satisfies c(s, a, s′) ≥ ε for some ε > 0. This ensures:
- Completeness: Path costs grow without bound along any infinite path, so UCS eventually considers all paths of bounded cost.
- Optimality: When a node is first expanded, no cheaper path to it can be found later (monotonicity of g values on the frontier).
Why not just “non-negative”? If zero-cost edges exist, UCS could loop infinitely through zero-cost cycles without making progress, breaking both completeness and optimality.
Answer: C. Every edge cost is strictly greater than some positive constant ε
Key Takeaway: The condition is c ≥ ε > 0, not merely c ≥ 0. This is a common GATE trap. Option A (unit costs) is sufficient but not necessary — UCS handles variable costs.
Question 9 — Bidirectional Search Advantage
The primary advantage of bidirectional search over BFS is a reduction in:
- Space complexity from O(bd) to O(bd/2)
- Time complexity from O(bd) to O(bd/2)
- Time complexity from O(bd) to O(d2)
- Both time and space complexity from O(bd) to O(bd/2)
Bidirectional search runs two simultaneous BFS searches: one from the start and one from the goal, meeting in the middle at depth d/2.
- Time: Each BFS explores O(bd/2) nodes, so total time is O(2 · bd/2) = O(bd/2).
- Space: Each frontier stores O(bd/2) nodes, so total space is O(bd/2).
Both time and space improve from O(bd) to O(bd/2), which is a massive reduction.
Answer: D. Both time and space from O(bd) to O(bd/2)
Key Takeaway: For b=10, d=6: normal BFS checks ~106 = 1,000,000 nodes; bidirectional checks ~2×103 = 2,000 nodes. The catch: bidirectional search requires an explicit goal state and reversible operators.
Question 10 — Strategy Selection (Conceptual)
You are solving a search problem with the following characteristics:
- Branching factor b = 10
- Solution depth d is unknown
- All step costs are equal (unit cost)
- Memory is severely limited (only ~100 KB available)
- You need an optimal solution
Which uninformed search strategy is most appropriate?
- BFS
- DFS
- Iterative Deepening DFS
- Uniform Cost Search
Let’s evaluate each option against the constraints:
- BFS: Complete & optimal (unit costs), but space = O(bd) = O(10d). Even at d=5, that’s 100,000 nodes — far exceeds 100 KB. ❌ Memory fails.
- DFS: Space = O(b·m) — manageable, but DFS is not optimal and may not even be complete. ❌ No optimality.
- IDDFS: Complete, optimal (unit costs), space = O(b·d) = O(10d). Even at d=20, that’s only 200 nodes — fits in 100 KB easily. Time overhead is just b/(b−1) = 10/9 ≈ 11%. ✅ All criteria met.
- UCS: Optimal, but space = O(bd) same as BFS. ❌ Memory fails. Also, UCS is overkill for unit costs.
Answer: C. Iterative Deepening DFS
Key Takeaway: IDDFS is the default choice when: (1) solution depth is unknown, (2) step costs are uniform, (3) memory is limited, and (4) optimality is required. It combines the best of BFS (completeness + optimality) with the best of DFS (linear space).
Exam Strategy Tips
- Trace methodically: For expansion-order questions, always maintain an explicit frontier (queue/stack/priority queue) on paper.
- Check goal test timing: Early goal test (on generation) vs. late goal test (on expansion) changes the node count.
- Memorise the formulas: BFS time = O(bd), BFS space = O(bd), DFS space = O(b·m), IDDFS space = O(b·d), UCS complete iff c ≥ ε > 0.
- Watch for traps: DFS is NOT complete in tree search. BFS is NOT optimal with non-uniform costs. UCS needs ε > 0, not just c ≥ 0.
- Use elimination: For 1-mark MCQs, quickly eliminate 2 wrong options, then carefully compare the remaining two.
- NAT precision: For numerical answers, double-check arithmetic. Common errors include off-by-one mistakes in node counts.