๐ State Space Search & Blind Search
364 words
2 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# ๐ State Space Search & Blind Search ## 1. ๐ฏ Learning Objectives - Define state space: states, operators, MoveGen, GoalTest - Trace DFS and BFS with full OPEN/CLOSED tables - Compare DFS (linear space) vs BFS (exponential space) - Explain when to use CLOSED list vs tree search ## 2.

๐ State Space Search & Blind Search
1. ๐ฏ Learning Objectives
- Define state space: states, operators, MoveGen, GoalTest
- Trace DFS and BFS with full OPEN/CLOSED tables
- Compare DFS (linear space) vs BFS (exponential space)
- Explain when to use CLOSED list vs tree search
2. ๐ Core Content
3.1 State Space Definition
A state space is a 5-tuple (S, sโ, A, T, G):
- S: Set of all states
- sโ: Initial state
- A: Actions/operators
- T: Transition function S ร A โ S
- G: Goal states MoveGen(s): Returns successors of state s. GoalTest(s): Returns True if s is a goal state.
3.2 OPEN and CLOSED Lists
| List | Purpose | Data Structure |
|---|---|---|
| OPEN | States generated but not expanded | DFS: Stack, BFS: Queue |
| CLOSED | States already expanded | Hash set |
3.3 DFS Trace Example
Graph: AโB, AโC, BโD, BโE, CโF, CโG. Goal = F.
| Step | OPEN (stack, top=right) | CLOSED | Current | Notes |
|---|---|---|---|---|
| 0 | [A] | {} | - | Start |
| 1 | [C, B] | {A} | A | Pop A. Push C then B |
| 2 | [C, E, D] | {A, B} | B | Pop B. Push E then D |
| 3 | [C, E] | {A, B, D} | D | Pop D. No successors (dead end) |
| 4 | [C] | {A, B, D, E} | E | Pop E. No successors |
| 5 | [G, F] | {A, B, D, E, C} | C | Pop C. Push G then F |
| 6 | [G] | {A, B, D, E, C, F} | F | Goal found! |
Path: A-C-F. Nodes inspected: A, B, D, E, C, F.
3.4 BFS Trace (Same Graph)
| Step | OPEN (queue, back=right) | CLOSED | Current | Notes |
|---|---|---|---|---|
| 0 | [A] | {} | - | Start |
| 1 | [B, C] | {A} | A | Dequeue A. Enqueue B, C |
| 2 | [C, D, E] | {A, B} | B | Dequeue B. Enqueue D, E |
| 3 | [D, E, F, G] | {A, B, C} | C | Dequeue C. Enqueue F, G |
| 4 | [E, F, G] | {A, B, C, D} | D | Dequeue D. Dead end |
| 5 | [F, G] | {A, B, C, D, E} | E | Dequeue E. Dead end |
| 6 | [G] | {A, B, C, D, E, F} | F | Goal found! |
Path: A-C-F (shortest path, also found by DFS in this case).
3.5 Key Differences
| Property | DFS | BFS |
|---|---|---|
| OPEN structure | Stack (LIFO) | Queue (FIFO) |
| Space | O(bd) | O(b^d) |
| Optimal? | No | Yes |
| Complete? | With CLOSED | Yes |
4. ๐ Practice Questions
Q1: Trace DFS on graph AโB, AโC, BโD, CโD with goal = D, alphabetical ordering.Answer: OPEN=[A]. Pop A โ [C,B]. Pop B โ [C,D]. Pop D โ Goal! Path: A-B-D. Nodes: A, B, D. Q2: For the same graph, trace BFS.Answer: OPEN=[A]. Dequeue A โ [B,C]. Dequeue B โ [C,D]. Dequeue C โ [D,D2]. Dequeue D โ Goal! Path: A-C-D. BFS finds shortest path (2 edges) vs DFS (2 edges, same here). Join Discord PreviousAI PhilosophyNextConfig vs Planning