CSC 494 · Introduction to Artificial Intelligence
Our notes
2 min readSearch trees
Search builds a tree from the initial state: the frontier holds nodes waiting to be expanded; the explored set avoids repeating states. Strategies differ in which node they expand next.
Comparing strategies
- Completeness: finds a solution if one exists?
- Optimality: finds the cheapest?
- Time and space complexity: in terms of b (branching factor), d (depth of the shallowest goal), m (maximum depth).
The strategies
| Strategy | Frontier | Complete? | Optimal? | Time | Space |
|---|---|---|---|---|---|
| Breadth-first (BFS) | queue (FIFO) | yes | yes if all step costs equal | O(b^d) | O(b^d) |
| Uniform-cost (UCS) | priority queue by path cost g | yes (positive costs) | yes | about O(b^(1 + C*/ε)) | same |
| Depth-first (DFS) | stack (LIFO) | no (infinite paths) | no | O(b^m) | O(bm) |
| Depth-limited | DFS to limit l | no if l < d | no | O(b^l) | O(bl) |
| Iterative deepening (IDS) | DFS with limits 0, 1, 2, ... | yes | yes if equal costs | O(b^d) | O(bd) |
| Bidirectional | from start and goal | yes | yes (with BFS) | O(b^(d/2)) | O(b^(d/2)) |
IDS combines BFS's completeness with DFS's small memory; it is the usual choice for large spaces with unknown depth.
Worked example
Graph: A → B, C; B → D, E; C → F; E → G. Start A, goal G. Children are taken left to right.
- BFS expands A, B, C, D, E, F, then finds G: order A, B, C, D, E, F, G. Path A-B-E-G.
- DFS expands A, B, D (dead end), E, then G: order A, B, D, E, G.
- IDS: limit 0: A; limit 1: A, B, C; limit 2: A, B, D, E, C, F; limit 3: A, B, D, E, G found.
Worked example: memory
With b = 10 and d = 6, BFS may keep about 10⁶ nodes (a million) in memory; DFS or IDS keeps about b × d = 60.
Uniform-cost search
Expands the node with the lowest path cost g(n), so it handles unequal step costs (road distances). It is Dijkstra's algorithm with a goal test.
Exams usually ask
- Describe BFS, DFS, UCS and IDS and compare them.
- Give the order of node expansion on a given graph.
Common mistake
Claiming DFS is optimal. DFS may find a long path first; BFS (equal costs) and UCS (any positive costs) are optimal.
Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.
Read
-
Breadth-first search
(opens en.wikipedia.org in a new tab)
Wikipedia, Breadth-first search, CC BY-SA 4.0 · licence
-
Depth-first search
(opens en.wikipedia.org in a new tab)
Wikipedia, Depth-first search, CC BY-SA 4.0 · licence
-
NPTEL: Artificial Intelligence: Search Methods for Problem Solving (IIT Madras, whole course)
Prof. Deepak Khemani: state space search, DFS and BFS, heuristic search, A*, problem decomposition, game playing with minimax and alpha-beta. Video lectures, many hours in all: watch on Wi-Fi where you can.
(opens nptel.ac.in in a new tab)
NPTEL, NPTEL: Artificial Intelligence: Search Methods for Problem Solving (IIT Madras, whole course), CC BY-NC-SA 4.0 · licence
-
NPTEL: Artificial Intelligence: Foundations and Algorithms (IIT Delhi, whole course)
Prof. Mausam: what AI is and its history, uninformed and informed search, local search, then reasoning and learning. Video lectures, many hours in all: watch on Wi-Fi where you can.
(opens nptel.ac.in in a new tab)
NPTEL, NPTEL: Artificial Intelligence: Foundations and Algorithms (IIT Delhi, whole course), CC BY-NC-SA 4.0 · licence
Watch
-
Best pick Informed And Uninformed Search | Search Algorithms in Artificial Intelligence | Simplilearn
8 min · ≈ 36 MB · about ₦20
(opens youtube.com in a new tab)
-
Artificial Intelligence - 3.4 - Uninformed search algorithms
29 min · ≈ 131 MB · about ₦74
(opens youtube.com in a new tab)
-
Introduction To Uninformed Search
4 min · ≈ 18 MB · about ₦10
(opens youtube.com in a new tab)
-
Lec 8: Uninformed Path Search Algorithms - Artificial Intelligence, Alan Blair, UNSW
28 min · ≈ 126 MB · about ₦71
(opens youtube.com in a new tab)
-
Artificial Intelligence - Uninformed Search Algorithms (Blind Search)
11 min · ≈ 50 MB · about ₦28
(opens youtube.com in a new tab)
-
Search - Lecture 0 - CS50's Introduction to Artificial Intelligence with Python 2020
1 h 50 min · ≈ 495 MB · about ₦278
(opens youtube.com in a new tab)
We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.