Uninformed Search & Traversal
Systematic graph exploration and local optimization. Step-by-step state space traces for Breadth-First Search (BFS), Depth-First Search (DFS), Depth-Limited Search (DLS) with cutoff limit $L=2$, Iterative Deepening Search (IDS), and Hill Climbing structural hazards.
01. Intuition & Concept Contrast
Uninformed (blind) search algorithms operate without domain heuristics; they know only how to generate successor states and test whether a state is the goal.
BFS (FIFO Queue) vs DFS (LIFO Stack)
Breadth-First Search (BFS): Expands the shallowest unexpanded node first. Explores level by level across the breadth. Complete and optimal for uniform step costs, but consumes exponential memory ($O(b^d)$) because it must store all active fringe nodes in RAM.
Depth-First Search (DFS): Expands the deepest unexpanded node first along a single path before backtracking. Incomplete on infinite trees and non-optimal, but uses modest linear memory ($O(bm)$).
DLS vs Iterative Deepening (IDS)
Depth-Limited Search (DLS): Enforces an artificial depth cutoff boundary at depth $L$. Solves DFS infinite-loop failures, but fails if the goal lies beyond depth $L$.
Iterative Deepening Search (IDS): Calls DLS with progressively increasing limits ($L = 0, 1, 2, \dots$). Combines the best of both worlds: optimal and complete like BFS, with the tiny linear memory footprint of DFS ($O(bd)$).
02. Comprehensive Search Properties Comparison Matrix
Guaranteed University Question (10 Marks). Comparing uninformed search algorithms across 4 standard criteria.
| Search Algorithm | Data Structure | Complete? | Optimal? | Time Complexity | Space Complexity |
|---|---|---|---|---|---|
| Breadth-First Search (BFS) | FIFO Queue | Yes (if $b$ finite) | Yes (if step cost = 1) | $O(b^d)$ | $O(b^d)$ (Exponential RAM) |
| Uniform-Cost Search (UCS) | Priority Queue (by $g$) | Yes (if costs $\ge \epsilon$) | Yes (Any step cost) | $O(b^{1 + \lfloor C^* / \epsilon \rfloor})$ | $O(b^{1 + \lfloor C^* / \epsilon \rfloor})$ |
| Depth-First Search (DFS) | LIFO Stack | No (infinite trees) | No (can find long path) | $O(b^m)$ | $\mathbf{O(bm)}$ (Linear!) |
| Depth-Limited Search (DLS) | LIFO Stack (Limit $L$) | Yes (if goal $d \le L$) | No | $O(b^L)$ | $\mathbf{O(bL)}$ |
| Iterative Deepening (IDS) | LIFO Stack (Repeated) | Yes (if $b$ finite) | Yes (if step cost = 1) | $O(b^d)$ | $\mathbf{O(bd)}$ (Optimal + Linear) |
03. Depth-Limited Search (DLS) Mechanics
Nov 2025 (Q3.b) Exam Walkthrough. Why DLS cuts off leaves and how it prevents infinite loops.
The Cutoff Protocol:
In standard DFS, the algorithm follows left branches indefinitely. If a tree has depth $m = \infty$, DFS gets trapped in an infinite loop.
DLS introduces a boundary $L$. When generating nodes at depth $L$:
- The algorithm visits and tests node at depth $L$.
- It **does NOT generate or expand any child nodes** beneath depth $L$.
- Child nodes are flagged as **pruned by cutoff**, and the search immediately backtracks to the parent level.
Students often assume IDS wastes time re-expanding upper levels. In an exponential tree with branching factor $b \ge 2$, the vast majority of nodes reside at the bottom level ($d$).
$$\text{Ratio} = \frac{b^d + b^{d-1} + \dots}{b^d} \approx \frac{b}{b - 1}$$ For $b = 10$, re-expansion overhead is only about $11\%$, a tiny price to pay for switching space complexity from gigabytes down to kilobytes!
04. Hill Climbing Local Search & The 3 Hazards
Nov 2025 (Q4.a) Guaranteed 5-Mark Question. Greedy local search without memory.
Local Maxima
A peak that is higher than all its immediate neighbors, but lower than the global optimum. Because hill climbing cannot take downhill moves, it gets stuck permanently.
Remedy: Random-Restart Hill Climbing (conduct multiple searches from uniformly distributed random start states).
Plateaus & Flat Shoulders
An area of the state space where the evaluation landscape is flat (zero gradient). All neighbors have the exact same score.
Remedy: Allow a limited number of sideways moves (e.g., max 100 sideways steps before aborting).
Ridges
A sequence of local peaks where the slope is steep along edges but gentle along the spine. The greedy search oscillates back and forth across the narrow ridge, making negligible progress along the spine.
Remedy: Simulated Annealing: Probabilistically accept suboptimal downhill moves based on temperature $T$ with Boltzmann probability $P = e^{\Delta E / T}$. As $T \to 0$, it settles smoothly into the global peak.
05. Notation Decoding Matrix
| Symbol | Formal Name | Plain-English Meaning | Exam Benchmark |
|---|---|---|---|
| $b$ | Branching Factor | Average number of child nodes generated per node | $b = 2$ in binary search trees |
| $d$ | Goal Depth | Depth of shallowest goal node in tree | $d = 2$ in Nov 2025 exam tree |
| $m$ | Maximum Depth | Deepest possible path in state space | $m = 3$ in Nov 2025 tree ($H, I, K$) |
| $L$ | Depth Limit | Pre-set cutoff boundary for Depth-Limited Search | $L = 2$ in Nov 2025 exam question |
| $\Delta E$ | Energy Difference | $\operatorname{Value}(n') - \operatorname{Value}(n)$ in Simulated Annealing | Negative when neighbor is worse |
06. Repeatable Step-by-Step Solving Protocol
Push Root node $A$ onto the LIFO stack: $\text{Stack} = [A]$.
Pop top node. If it matches Goal node, halt and output path.
To visit Left children before Right children, push Right child first, then Left child so Left is at the top of the LIFO stack!
If node depth $= L$, do NOT push its successors to the stack. Mark sub-branches as cutoff and backtrack immediately.
List visited nodes separated by arrows: $A \to B \to \dots \to G$.
07. 6 Deadly Exam Traps & Common Student Mistakes
Pushing Left Child Before Right Child
In a LIFO stack, the last item pushed is the first popped. If you push Left child first, the Right child will be popped first! Push Right child first to explore Left first.
Listing Leaves at Depth $L+1$
In DLS with $L=2$, nodes $H, I, K$ at depth 3 must NEVER appear in the visited list. They are pruned at depth 2.
Confusing BFS Space with DFS Space
BFS uses exponential space $O(b^d)$. DFS uses tiny linear space $O(bm)$. Claiming DFS has high space complexity is an automatic mark deduction.
Assuming Hill Climbing Can Backtrack
Hill Climbing maintains zero search tree history. It remembers only its current state. Once stuck at a local maximum, it cannot backtrack on its own.
Continuing Search After Goal is Reached
When the Goal node (Node G) is popped and visited, the algorithm must halt immediately. Do not continue exploring remaining stack items.
Starting Depth Count at 1 Instead of 0
Root node $A$ is at **Depth 0**. Level 1 children are at Depth 1. Counting Root as Depth 1 shifts your cutoff limit by an entire level.
08. Complete University Question Bank (All Past PYQs Solved)
Nov 2025 · Question 3 Complete DFS vs DLS Traversal on 10-Node Tree (20 Marks)
Given the tree configuration below, perform DFS traversal starting from root A. (10 Marks)
Perform Depth-Limited Search (DLS) with depth limit $L = 2$. Compare both methods. (10 Marks)
Solution:
a) Depth-First Search (DFS) Traversal Trace (10 Marks):
- Visit A: Push right child $C$, then left child $B$. Stack: $[C, B]$.
- Pop & Visit B: Push right child $E$, then left child $D$. Stack: $[C, E, D]$.
- Pop & Visit D: Push child $H$. Stack: $[C, E, H]$.
- Pop & Visit H: Leaf node at depth 3. Backtrack. Stack: $[C, E]$.
- Pop & Visit E: Push child $I$. Stack: $[C, I]$.
- Pop & Visit I: Leaf node at depth 3. Backtrack. Stack: $[C]$.
- Pop & Visit C: Push right child $G$, then left child $F$. Stack: $[G, F]$.
- Pop & Visit F: Push child $K$. Stack: $[G, K]$.
- Pop & Visit K: Leaf node at depth 3. Backtrack. Stack: $[G]$.
- Pop & Visit G: **Goal node reached! Search halts.**
DFS Visited Order (10 Nodes):
$$\mathbf{A \to B \to D \to H \to E \to I \to C \to F \to K \to G}$$
b) Depth-Limited Search (DLS) with Limit $L = 2$ (10 Marks):
- Depth 0: Visit **A**. Push children $C, B$.
- Depth 1: Visit **B**. Push children $E, D$.
- Depth 2 (Limit Reached): Visit **D**. Because Depth $= L = 2$, child $H$ is **cutoff / pruned**! Backtrack.
- Depth 2 (Limit Reached): Visit **E**. Child $I$ is **cutoff / pruned**! Backtrack to $C$.
- Depth 1: Visit **C**. Push children $G, F$.
- Depth 2 (Limit Reached): Visit **F**. Child $K$ is **cutoff / pruned**! Backtrack to $G$.
- Depth 2 (Limit Reached): Visit **G**. **Goal node reached! Search halts successfully.**
DLS Visited Order ($L = 2$, 7 Nodes):
$$\mathbf{A \to B \to D \to E \to C \to F \to G}$$
*(Nodes $H, I, K$ at depth 3 were completely pruned by cutoff).*
c) Comprehensive Comparison Table:
| Dimension | Depth-First Search (DFS) | Depth-Limited Search (DLS, $L=2$) |
|---|---|---|
| Nodes Visited | 10 nodes | 7 nodes (3 leaf nodes pruned) |
| Search Efficiency Here | Wastes time exploring $H, I, K$ | More efficient; reaches goal faster |
| Infinite Path Trap | Vulnerable on infinite trees | Immune; strictly bounds depth |
| Space Complexity | $O(bm)$ | $O(bL)$ |
Nov 2025 · Question 4.a Hill Climbing Algorithm Principles & 3 Structural Hazards (5 Marks)
Explain the Hill Climbing algorithm and list its drawbacks. (5 Marks)
Solution:
1. Working Principle:
Hill climbing is an informed local search optimization technique. It inspects immediate neighboring states and moves greedily to whichever state improves the objective function. It terminates when no neighbor is better than the current state. Maintains zero search history ($O(1)$ space).
2. The Three Critical Structural Drawbacks:
- Local Maxima: A suboptimal peak higher than all immediate neighbors but lower than the global optimum. Algorithm halts prematurely.
- Plateaus & Flat Shoulders: A flat region of identical evaluation values (zero gradient), causing unguided random walks.
- Ridges: A sequence of connected local peaks with steep sides and a gentle spine, causing inefficient zig-zag oscillations across the slope.
May 2025 · Question 7.i BFS vs DFS Working Principles & Data Structures (10 Marks)
Explain working principle of BFS and DFS algorithms with a step-by-step illustration on a sample graph. (10 Marks)
Solution:
1. Breadth-First Search (BFS):
- Data Structure: First-In, First-Out (**FIFO**) Queue.
- Principle: Explores all nodes at depth $k$ before examining any node at depth $k+1$.
- Optimality & Completeness: Guaranteed optimal for uniform edge costs; complete on finite branching. Exponential memory $O(b^d)$.
2. Depth-First Search (DFS):
- Data Structure: Last-In, First-Out (**LIFO**) Stack.
- Principle: Descends along a single branch to maximum depth before backtracking.
- Memory Advantage: Consumes only linear memory $O(bm)$, making it feasible on deep trees where BFS exhausts RAM.
09. Interactive Offline Search Traversal Simulator
Compare DFS vs DLS node visits live on the exam tree structure.
10. Active Recall Self-Test Quiz
11. Exam Hall Answer Sheet Presentation Checklist
Write Depth 0 for Root A, Depth 1 for B/C, Depth 2 for D/E/F/G, Depth 3 for H/I/K.
Explicitly write stack contents at each step (e.g. $[C, B] \to [C, E, D] \dots$).
Write: "Nodes H, I, K are pruned because their depth 3 > limit L = 2."
Box: DFS = $A \to B \to D \to H \to E \to I \to C \to F \to K \to G$ (10 nodes).
Box: DLS = $A \to B \to D \to E \to C \to F \to G$ (7 nodes).
Draw quick sketches of: (1) Local Maxima, (2) Plateau/Shoulder, (3) Ridge.