CSC 494 · Introduction to Artificial Intelligence
Our notes
2 min readHeuristics
A heuristic function h(n) estimates the cost from node n to the nearest goal, using knowledge of the problem. Examples:
- Route finding: straight-line distance to the destination.
- 8-puzzle: h₁ = number of misplaced tiles; h₂ = Manhattan distance (sum of each tile's horizontal and vertical distance from its goal square).
Greedy best-first search
Expands the node with the smallest h(n). Fast, but not optimal and not always complete: it can be lured down paths that look close but are expensive.
A* search
Expands the node with the smallest f(n) = g(n) + h(n): cost so far plus estimated cost to go.
- Admissible h never overestimates the true cost: then A* (tree search) is optimal.
- Consistent (monotone) h: h(n) ≤ cost(n, n′) + h(n′) for every step; then A* graph search is optimal and never needs to reopen nodes.
Worked example: A*
Edges (costs): S-A 1, S-B 4, A-B 2, A-G 10, B-G 3. Heuristic: h(S) = 5, h(A) = 4, h(B) = 3, h(G) = 0 (admissible: true costs to G are 6, 5, 3, 0).
- Expand S (f = 0 + 5 = 5). Add A (g 1, f 5) and B (g 4, f 7).
- Expand A (f 5). B via A: g 3, f 6 (better than 7, update). G via A: g 11, f 11.
- Expand B (f 6). G via B: g 6, f 6 (better than 11).
- Expand G (f 6): goal.
Path S-A-B-G, cost 6 (optimal; the direct A-G route costs 11).
Greedy search would expand S, then B (h 3 < 4), then G: path S-B-G cost 7, not optimal.
Comparing 8-puzzle heuristics
Both h₁ and h₂ are admissible; h₂ ≥ h₁ for every state (h₂ dominates h₁), so A* with h₂ expands fewer nodes.
Local search
For problems where only the final state matters (scheduling, 8-queens, timetable design):
- Hill climbing: move to the best neighbour; can get stuck on local maxima and plateaus.
- Simulated annealing: sometimes accepts worse moves, less often as "temperature" falls.
- Genetic algorithms: a population of solutions with selection, crossover and mutation.
Exams usually ask
- Define heuristic, admissible and consistent heuristics.
- Trace A* (or greedy) on a graph and give the path and cost.
- Compare greedy best-first search with A*.
Common mistake
Stopping A* as soon as the goal is generated. A* is optimal only if you stop when the goal is selected for expansion (removed from the frontier).
Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.
Read
-
A* search algorithm
(opens en.wikipedia.org in a new tab)
Wikipedia, A* search algorithm, CC BY-SA 4.0 · licence
-
Heuristic (computer science)
(opens en.wikipedia.org in a new tab)
Wikipedia, Heuristic (computer science), 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.5 - Informed (heuristic) search strategies
22 min · ≈ 99 MB · about ₦56
(opens youtube.com in a new tab)
-
A* Search
13 min · ≈ 59 MB · about ₦33
(opens youtube.com in a new tab)
-
A* (A Star) Search and Heuristics Intuition in 2 minutes
2 min · ≈ 9 MB · about ₦5
(opens youtube.com in a new tab)
-
BFS algorithm | informed search | AI | Artificial intelligence | Lec-18 | Bhanu Priya
8 min · ≈ 36 MB · about ₦20
(opens youtube.com in a new tab)
-
[CS188 SP24] LEC03 - Search: Informed Search, A*, Heuristics
1 h 14 min · ≈ 333 MB · about ₦187
(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.