Greedy Best-First Search
What you'll learn: How to speed up search by always choosing the path that looks closest to the goal, even if it might not be the shortest route.
The Core Idea
Greedy Best-First Search is an informed search algorithm that expands nodes based purely on how promising they look according to a heuristic function. At each step, it picks the node from the frontier that has the smallest heuristic value h(n)—meaning the node that appears closest to the goal.
Think of it like navigating to a destination using only a compass. You always walk in the direction that brings you closest to where you think the goal is, ignoring how far you've already traveled. You're "greedy" because you focus entirely on immediate progress toward the goal.
How It Works
The algorithm maintains a frontier (typically a priority queue) ordered by h(n). When choosing which node to expand next, it always selects the one with the lowest heuristic estimate—the one that seems nearest to the goal.
Unlike Uniform-Cost Search (which considers path cost g(n)), Greedy Best-First Search only cares about the heuristic. This makes it fast when the heuristic is good, but it can lead you down dead ends if the heuristic is misleading.
Strengths and Weaknesses
Fast when the heuristic is accurate: If your estimate is reliable, you'll beeline toward the goal efficiently.
Not optimal: Greedy Best-First Search doesn't guarantee the shortest path—it might find a solution quickly, but not necessarily the best one.
Not complete in graph search: It can get stuck in loops if not using an explored set.
Key Takeaway: Greedy Best-First Search is a fast, heuristic-driven strategy that always expands the node appearing closest to the goal, trading optimality for speed.