Greedy Best-First Search
Explained with Example Problem
What is Greedy Best-First Search?
• Greedy Best-First Search is an informed search
algorithm that uses a heuristic function h(n).
• It expands the node that appears to be closest
to the goal using h(n).
• Evaluation function: f(n) = h(n)
• Not guaranteed to be optimal or complete.
Problem Statement
• Find the shortest route from City A to City G
using Greedy Best-First Search.
• Cities are connected with paths, and each city
has a heuristic value estimating distance to G.
Graph of Cities
• A
• /\
• 1/ \3
• / \
• B C
• /\ /\
• 3/ \5 2/ \2
• / \/ \
• D E F
Heuristic Values h(n)
• A: 7
• B: 6
• C: 4
• D: 5
• E: 2
• F: 1
• G: 0
Step-by-Step Execution
• Start at A
• Step 1: A → C (h=4)
• Step 2: C → F (h=1)
• Step 3: F → G (h=0)
• Path Found: A → C → F → G
Summary
• Algorithm Type: Informed Search
• Evaluation Function: f(n) = h(n)
• Pros: Fast, simple
• Cons: Not always optimal, may get stuck in
local minima