CSC266 · 2081 · 5 marks
How uniform cost search is used to search goal in the state apace? Illustrate with example.
How uniform cost search is used to search goal in the state apace? Illustrate with example. [5]
Uniform Cost Search (UCS) in State Space
Given Data
This is a conceptual/descriptive question. No numeric matrices, burst times, or reference strings are provided. The example graph and edge costs are constructed for illustration (as the question requires "an example").
Definition
Uniform Cost Search (UCS) is an uninformed (blind) search strategy that expands the node with the lowest cumulative path cost $g(n)$ from the start node. It is a special case of Best-First Search using the evaluation function:
$$f(n) = g(n)$$
where $g(n)$ = total cost of the path from the start state to node $n$. When all step costs are equal, UCS reduces to Breadth-First Search.
How UCS Searches the Goal
- Insert the start node into a priority queue ordered by path cost (minimum first), with cost $0$.
- Remove the node with the least path cost.
- Goal test at expansion (when popped, not when generated) to guarantee optimality.
- Generate successors; for each, compute $g(\text{child}) = g(\text{parent}) + \text{step cost}$ and insert into the priority queue.
- If a cheaper path to an already-seen node is found, update it.
- Repeat until the goal is popped or the queue is empty.
Illustrated Example
Consider a weighted graph with start $S$ and goal $G$:
Edge costs:
- $S \to A = 1$
- $S \to B = 4$
- $A \to B = 2$
- $A \to G = 5$
- $B \to G = 2$
Step-by-Step Trace
| Step | Priority Queue (node, cost) | Expanded | Action |
|---|---|---|---|
| 1 | {(S,0)} | S (0) | Add A(1), B(4) |
| 2 | {(A,1),(B,4)} | A (1) | Add G(1+5=6); B via A = 1+2=3 (better than 4) |
| 3 | {(B,3),(G,6)} | B (3) | Add G(3+2=5) |
| 4 | {(G,5),(G,6)} | G (5) | Goal found |
Optimal Path: $S \to A \to B \to G$ with total cost $= 1 + 2 + 2 = \mathbf{5}$
The alternative $S \to A \to G$ costs $6$, so UCS correctly returns the cheaper path.
Check the path, not just the cost: with $S \to A = 1$ and $A \to B = 2$, node $B$ is reached at cost $3$, so the optimal path is $S \to A \to B \to G$ rather than $S \to B \to G$. The final cost (5) is identical either way.
Performance Measures
| Criterion | Result |
|---|---|
| Completeness | Complete if every step cost $\ge \varepsilon > 0$ |
| Optimality | Optimal (least-cost path) |
| Time Complexity | $O\big(b^{1 + \lfloor C^{*}/\varepsilon \rfloor}\big)$ |
| Space Complexity | $O\big(b^{1 + \lfloor C^{*}/\varepsilon \rfloor}\big)$ |
where $C^{*}$ = cost of optimal solution, $\varepsilon$ = minimum step cost, $b$ = branching factor.
Key Points
- Uses a priority queue ordered by $g(n)$.
- Optimal and complete for positive step costs.
- Uninformed counterpart of A* (A* adds heuristic: $f(n)=g(n)+h(n)$).
- Goal tested at expansion, ensuring no cheaper path is missed.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.