loader

Explore Categories

Certifications
Certified ScrumMaster (CSM) certification badge
2 DaysLive ClassesPopular
Certified ScrumMaster® (CSM®) Certification
Certified Scrum Product Owner (CSPO) certification badge
2 DaysLive ClassesPopular
Certified Scrum Product Owner (CSPO®) Certification
Certified Scrum Developer (CSD) certification badge
2 DaysLive ClassesPopular
Certified Scrum Developer (CSD®) Certification
1 DaysLive ClassesPopular
Agile and Scrum
PMI Agile Certified Practitioner (PMI-ACP) certification badge
3 DaysLive ClassesPopular
PMI Agile Certified Practitioner (PMI-ACP)® Certification
Professional Scrum Master I (PSM I) certification badge
2 DaysLive ClassesPopular
Professional Scrum Master™ (PSM I) Certification
Certified Agile Service Provider certification badge
2 DaysLive ClassesTrending
Certified Agile Scaling Practitioner™ 1 (CASP 1)
Certified Agile Facilitator (CAF) certification badge
2 DaysLive ClassesTrending
Agile Coaching Skills - Certified Facilitator™ (CAF)
Certified Agile Leadership I (CAL 1) certification badge
2 DaysLive ClassesPopular
Certified Agile Leader® 1 (CAL 1™) Certification
3 DaysLive ClassesPopular
ICAgile Certified Professional in Agile Coaching (ICP-ACC®) Certification
Professional Scrum with Kanban (PSK) certification badge
2 DaysLive ClassesPopular
Professional Scrum with Kanban™ (PSK) Certification
Professional Scrum Developer (PSD) certification badge
3 DaysLive ClassesPopular
Professional Scrum Developer (PSD) Certification
Certified Scrum Professional - ScrumMaster (CSP-SM) certification badge
2 DaysLive ClassesPopular
Certified Scrum Professional - ScrumMaster (CSP®-SM) Certification
Certified Agile Leadership II (CAL 2) certification badge
2 DaysLive ClassesTrending
Certified Agile Leader® 2 (CAL 2™) Certification
2 DaysLive Classes
ICAgile Coaching Agile Transformations (ICP-CAT) Certification
Professional Agile Leadership Essentials (PAL-E) certification badge
2 DaysLive Classes
Professional Agile Leadership Essentials™ (PAL-E) Certification
2 DaysLive Classes
Behaviour Driven Development (BDD)
2 DaysLive Classes
Test Driven Development (TDD)
2 DaysLive Classes
ICAgile Agility in the Enterprise (ICP-ENT) Certification
2 DaysLive Classes
ICAgile(ICP) Fundamental Certification
2 DaysLive Classes
Manage Agile Projects Using Scrum
2 DaysLive Classes
Agile for Executives
2 DaysLive Classes
Agile for Managers
2 DaysLive Classes
Agile Product Owner
Applying Professional Scrum (APS) certification badge
2 DaysLive Classes
Applying Professional Scrum™ (APS) Certification
2 DaysLive Classes
Agile Release Planning
2 DaysLive Classes
Agile Project Management
Jira Agile project management tool logo
2 DaysLive ClassesTrending
Jira Software for Agile Projects
ICAgile-ICP-LEA-logo
2 DaysLive Classes
ICAgile Agile Leadership (ICP-LEA) Certification Course
ICAgile Product Management (ICP-PDM) Certification badge
2 DaysLive Classes
ICAgile Product Management (ICP-PDM) Certification
ICAgile ICP-APM logo
2 DaysLive Classes
ICAgile Agile Project & Delivery Management (ICP-APM)
1 DaysLive Classes
Professional Scrum Product Backlog Management (PSPBM) Skills™ Certification Course
ICAgile ICP-APO logo
2 DaysLive Classes
ICAgile Agile Product Ownership (ICP-APO) Certification
APK Course
2 DaysLive Classes
Applying Professional Kanban(APK) Course
ICAgile ICP-ATF Service logo
2 DaysLive Classes
ICAgile Agile Team Facilitation Certification (ICP-ATF)
ICP-FAI course logo
2 DaysLive Classes
ICAgile Foundations of AI (ICP-FAI) Certification
ICAgile ICP-LPM logo
2 DaysLive Classes
ICAgile Lean Portfolio Management (ICP-LPM) Certification
ICAgile ICP-PDM logo
2 DaysLive Classes
ICAgile People Development (ICP-PDV) Certification
ICAgile ICP-SYS logo
2 DaysLive Classes
ICAgile Systems Coaching (ICP-SYS) Certification
ICAgile ICP-BAF logo
2 DaysLive Classes
ICAgile Business Agility Foundations (ICP-BAF) Certification
Professional Scrum Master with AI Skills certification badge
1 DaysLive Classes
Professional Scrum Master AI Essentials Certification
Professional Scrum Product Owner (PSPO) with AI Skills certification badge
1 DaysLive Classes
Professional Scrum Product Owner–AI Essentials (PSPO-AI Essentials) Certification
ICP-ORG Logo
2 DaysLive Classes
ICAgile Adaptive Org Design (ICP-ORG) Certification
Advanced Certifications

SAFe Category

CertificationsAdvanced CertificationsMaster Certifications

Generative AI

View all Courses
Certifications
2 DaysLive Classes
Generative AI for Business & IT Leaders & Managers
2 DaysLive Classes
Generative AI for Business Analysts & Functional IT Consultants
2 DaysLive Classes
Cloud Fundamentals for Business Managers & Product Managers
2 DaysLive Classes
Generative AI Architect - Advanced Program
1 DaysLive Classes
Introduction to Generative AI
2 DaysLive Classes
Generative AI for Agile Leaders
2 DaysLive Classes
Generative AI for Scrum Masters
2 DaysLive Classes
Generative AI in HR Certification Course
2 DaysLive Classes
Generative AI for Software Developers Course
2 DaysLive Classes
Generative AI for Project Managers
2 DaysLive Classes
Prompt Engineering Course
2 DaysLive Classes
Generative AI for Product Owners-Product Managers Certification
2 DaysLive Classes
Mastering Generative AI Tools Online
3 DaysLive Classes
Agentic AI Foundation Course
3 DaysLive Classes
Agentic AI Practitioner Course
11 DaysLive Classes
Claude Certified Architect – Foundations (CCA-F) Course
2 DaysLive ClassesTrending
AI For CXOs Workshop
6 DaysLive ClassesPopular
Agentic AI Engineering with Anthropic Claude Technologies Course
13 DaysLive Classes
Forward Deployed Architect Program
2 DaysLive Classes
AI-Native Development Using BDD
6 DaysLive Classes
Agentic AI with Azure AI Foundry Program
7 DaysLive Classes
Agentic AI for Software Testers Workshop
32 DaysLive Classes
Artificial Intelligence Governance Professional
60 DaysLive Classes
Agentic AI Engineering Workshop
6 DaysLive Classes
Production Grade AI Applications & SDLC Automation with OpenAI Technologies Workshop
5 DaysLive Classes
Agentic AI with AWS Bedrock Workshop
7 DaysLive Classes
AI Engineering with GCP Vertex AI Workshop
24 DaysLive Classes
Agentic and Generative AI Workshop for IT Services Business Leaders & Managers
1 DaysLive Classes
Forward Deployed Engineering Program
1 DaysLive Classes
Business Productivity & Automation with Agentic AI Workshop
1 DaysLive Classes
Agentic AI for Business Transformation Workshop

Best First Search in AI: How It Works, Pseudocode, and Comparison With A Comparison

Labham Mishra

By Labham Mishra

26th Aug, 2026

views

Professional development article
Best First Search in AI: How It Works, Pseudocode, and Comparison With A Comparison

Quick Answer

Best First Search is an informed (heuristic-driven) search strategy in artificial intelligence that expands the node it judges most promising at each step, instead of expanding nodes strictly by depth (as in Depth-First Search) or by insertion order (as in Breadth-First Search). It does this by keeping a priority queue of frontier nodes ordered by an evaluation function f(n), and always popping the node with the best (typically lowest) f-value. Greedy Best First Search and A* Search are the two most important members of this family: Greedy Best First Search uses f(n) = h(n) and is fast but not guaranteed optimal, while A* uses f(n) = g(n) + h(n) and is both complete and optimal when the heuristic is admissible.

Key Highlights of Best First Search in AI

  • Best First Search generalizes uninformed search by adding a heuristic function h(n) that estimates the cost from any node to the goal, letting the algorithm prioritize which node to expand next rather than expanding nodes blindly.
  • The algorithm relies on two core data structures: an OPEN list (a priority queue of frontier nodes ordered by f-value) and a CLOSED list (already-expanded nodes), a structure that traces back to Doran and Michie's 1966 "Graph Traverser" program at the University of Edinburgh.
  • Greedy Best First Search (f(n) = h(n)) is neither complete nor optimal and can get trapped following a locally attractive but globally poor path, while A* Search (f(n) = g(n) + h(n)) is optimal and complete whenever the heuristic is admissible (never overestimates true cost).
  • Worst-case time and space complexity for best-first search is O(b^m), where b is the branching factor and m is the maximum search depth, though A* with a good heuristic performs far better in practice than this bound suggests.
  • On the classic Romania route-finding problem (from AIMA, Russell and Norvig's widely used AI textbook), Greedy Best First Search reaches Bucharest quickly using straight-line distance as h(n), but takes a longer route than A*, which accounts for both the distance already traveled and the estimated remaining distance.
  • Modern GPS navigation, video game pathfinding, and robot motion planning all rely on best-first search variants (mainly A* and its extensions) because they scale to enormous graphs while still finding good, and often provably optimal, paths.

What Is Best First Search in AI

In artificial intelligence, a search problem is typically defined by a start state, a set of possible actions that move between states, a goal test, and (often) a cost associated with each action. Search algorithms explore the resulting state space, represented as a graph or tree, to find a sequence of actions from the start to a goal.

Search strategies fall into two broad families. Uninformed (blind) search algorithms, such as Breadth-First Search and Depth-First Search, have no information about which unexplored node is more likely to lead to the goal; they explore based purely on the structure of the search tree. Informed (heuristic) search algorithms, by contrast, use problem-specific knowledge, encoded as a heuristic function h(n), to estimate how close a given node n is to the goal, and use that estimate to guide exploration.

Best First Search is the general name for the class of informed search algorithms that always expand the node currently judged "best" according to some evaluation function f(n), where the frontier (the set of nodes discovered but not yet expanded) is maintained as a priority queue ordered by f(n). The specific definition of f(n) determines which particular algorithm you get. When f(n) = h(n) alone, the result is Greedy Best First Search. When f(n) = g(n) + h(n), where g(n) is the actual cost from the start node to n, the result is A* Search. Because A* and Greedy Best First Search share this "always expand the best frontier node" structure, both are correctly described as best-first search algorithms, and in practice "best-first search" and "greedy best-first search" are sometimes used loosely to mean the same thing, which is a common source of confusion worth clearing up early.

This distinction matters directly for anyone building toward a career in applied AI or machine learning; understanding how search and optimization strategies trade off speed against guaranteed correctness is foundational material in most structured Artificial Intelligence certification training curricula, since the same trade-off reappears constantly in planning, scheduling, and optimization problems well beyond simple pathfinding.

Origins: From the Graph Traverser to Modern Heuristic Search

The idea of guiding search with an evaluation function is not new. One of the earliest documented implementations is the "Graph Traverser" program, built by J. E. Doran and Donald Michie at the Experimental Programming Unit, University of Edinburgh, and described in their 1966 paper "Experiments with the Graph Traverser Program," published in Proceedings of the Royal Society of London A. The Graph Traverser evaluated intermediate states according to how many features they shared with the goal state, using an evaluation function to decide which state to expand next, which is precisely the mechanism modern best-first search still uses.

That early work set the stage for more rigorous heuristic search theory through the 1960s and 1970s, culminating in the formalization of A* Search by Peter Hart, Nils Nilsson, and Bertram Raphael in 1968, and later the systematic treatment given in Stuart Russell and Peter Norvig's textbook "Artificial Intelligence: A Modern Approach" (AIMA), which remains the standard reference most university AI courses, including those at UC Berkeley and MIT, build their informed search material around.

How Best First Search Works

Best First Search operates on a graph (or an implicit tree generated by expanding states one action at a time) and maintains two collections of nodes:

  • OPEN list (the frontier): a priority queue holding nodes that have been generated but not yet expanded, ordered by their f-value so the node with the best score is always at the front.
  • CLOSED list (the explored set): nodes that have already been expanded, kept so the algorithm does not waste time re-expanding them (in graph search) or, in some variants, purely for bookkeeping and path reconstruction.

At a high level, the algorithm proceeds as follows:

  1. Place the start node on OPEN with its initial f-value.
  2. Loop: if OPEN is empty, report failure (no solution exists).
  3. Remove the node with the lowest f-value from OPEN; call it n.
  4. If n is a goal state, reconstruct the path from the start to n (using stored parent pointers) and return it as the solution.
  5. Otherwise, move n to CLOSED and generate its successors (the states reachable from n via a single action).
  6. For each successor, compute its f-value. If it is not already in OPEN or CLOSED, add it to OPEN. If it is already present with a worse recorded cost, update its cost and parent pointer (this update step is what allows A* to correct an earlier suboptimal path estimate).
  7. Return to step 2.

The entire behavior of the algorithm, and specifically whether it behaves like Greedy Best First Search or like A*, is determined by how f(n) is defined:

  • Greedy Best First Search: f(n) = h(n). The algorithm always moves toward the node that looks closest to the goal right now, completely ignoring how much it already cost to get there.
  • A* Search: f(n) = g(n) + h(n). The algorithm balances the cost already incurred (g) against the estimated remaining cost (h), which is what allows it to avoid greedily committing to a path that looks good locally but is expensive overall.
  • Uniform Cost Search (for comparison): f(n) = g(n), i.e., h(n) = 0 for all n. This is technically a degenerate case of best-first search with no heuristic guidance at all, and it behaves identically to Dijkstra's algorithm on a graph with non-negative edge weights.

Best First Search Pseudocode

The following pseudocode describes generalized best-first search; substituting the definition of f(n) turns it into Greedy Best First Search or A* Search.

function BEST-FIRST-SEARCH(problem, f):
    node <- NODE(state = problem.INITIAL, path_cost = 0)
    frontier <- a priority queue ordered by f, initially containing node
    reached <- a lookup table, with one entry: {problem.INITIAL: node}

    while frontier is not empty:
        node <- POP node with lowest f-value from frontier
        if problem.IS-GOAL(node.state):
            return node   // success: reconstruct path via parent pointers

        for each child in EXPAND(problem, node):
            s <- child.state
            if s is not in reached OR child.path_cost < reached[s].path_cost:
                reached[s] <- child
                add child to frontier with priority f(child)

    return failure  // frontier exhausted, no solution

function EXPAND(problem, node):
    s <- node.state
    for each action in problem.ACTIONS(s):
        s_next <- problem.RESULT(s, action)
        cost <- node.path_cost + problem.ACTION-COST(s, action, s_next)
        yield NODE(state = s_next, parent = node, path_cost = cost)

To get Greedy Best First Search, define f(node) = h(node.state). To get A* Search, define f(node) = node.path_cost + h(node.state), which is exactly g(n) + h(n). This structural similarity is why implementations of A* and Greedy Best First Search in most textbooks and libraries differ by a single line: the definition of the priority function passed to an otherwise identical frontier-management routine.

Worked Example: Finding a Route on the Romania Map

The most widely used worked example for best-first search comes from Russell and Norvig's AIMA textbook: finding a driving route from Arad to Bucharest on a simplified map of Romania. Each city is a node, each road is an edge weighted by real driving distance, and the heuristic h(n) used is the straight-line ("as the crow flies") distance from a city to Bucharest. A small excerpt of that straight-line distance table is:

CityStraight-Line Distance to Bucharest (h value)
Arad366
Sibiu253
Fagaras178
Pitesti98
Bucharest0

Greedy Best First Search, starting at Arad: Arad's neighbors include Sibiu, Timisoara, and Zerind. Greedy search picks whichever neighbor has the lowest h-value, ignoring road distance entirely. Sibiu (h = 253) looks far more promising than Timisoara or Zerind, so it is expanded next. From Sibiu, one neighbor is Fagaras (h = 178), which looks better than the alternative route through Rimnicu Vilcea and Pitesti, so greedy search commits to Fagaras. From Fagaras, Bucharest (h = 0) is reachable directly, so the algorithm terminates having found the path Arad, Sibiu, Fagaras, Bucharest. This path is found quickly, but it is not the shortest one: the actual road distance via Sibiu, Rimnicu Vilcea, and Pitesti is shorter, a discrepancy Greedy Best First Search cannot detect because it never considers g(n), the cost already paid.

A* Search, starting at Arad: A* evaluates f(n) = g(n) + h(n) at every step, so it keeps both the accumulated road distance and the straight-line estimate in view. Early on this can make A* favor the Sibiu, Rimnicu Vilcea, Pitesti branch, because even though Pitesti's straight-line distance to Bucharest is worse than Fagaras's in isolation, the combined g + h score along that branch turns out lower once real driving distances are added in. A* ultimately returns the truly shortest path, Arad, Sibiu, Rimnicu Vilcea, Pitesti, Bucharest, because it never commits to a branch until the priority queue proves no better-scoring alternative remains.

This example illustrates the core trade-off of the entire best-first search family in one comparison: Greedy Best First Search reaches a goal fast by trusting the heuristic completely, while A* takes the accumulated cost into account and is guaranteed to find the optimal path whenever the heuristic is admissible.

Greedy Best First Search vs A* Search

Because both algorithms are instances of best-first search, the difference comes down entirely to the evaluation function and its consequences:

  • What each ignores: Greedy Best First Search ignores the cost already paid to reach a node (g(n)). A* ignores nothing; it uses both g(n) and h(n).
  • Optimality: Greedy Best First Search is not guaranteed to find the optimal (lowest-cost) solution, because a node with a very attractive h-value can sit at the end of an expensive path. A* is guaranteed optimal when the heuristic function is admissible (never overestimates the true remaining cost), because the algorithm cannot terminate on a goal node until it can prove, from the priority queue, that no cheaper path remains unexplored.
  • Completeness: Both algorithms are complete on finite graphs with non-negative edge costs; on infinite or unbounded state spaces, Greedy Best First Search can fail to terminate if it repeatedly follows an unproductive heuristic gradient, while A* still terminates given a finite state space.
  • Speed: In practice, Greedy Best First Search often expands fewer nodes and runs faster than A*, precisely because it commits early and does not verify optimality, which is why some applications (e.g., real-time game AI where "good enough, fast" beats "optimal, slow") deliberately choose greedy search or a weighted hybrid.
  • Memory: Both keep the entire frontier and (in graph search) explored set in memory, so both share the same worst-case space complexity, though A* frontiers can grow larger in practice because it explores more branches before committing.

Heuristic Function Properties: Admissibility and Consistency

The theoretical guarantees of A* Search depend entirely on properties of the heuristic function h(n), so understanding these two properties is essential to using best-first search correctly rather than just running it.

Admissibility

A heuristic h(n) is admissible if it never overestimates the true cost of reaching the goal from n; formally, h(n) ≤ h*(n) for every node n, where h*(n) is the actual optimal cost from n to the nearest goal. Straight-line distance is admissible for road-network routing because a straight line is always the shortest possible path between two points, so it can never exceed the true (necessarily longer, road-following) driving distance. Admissibility is the minimum requirement for A* Search (using tree search) to be guaranteed optimal.

Consistency (Monotonicity)

A heuristic h(n) is consistent if, for every node n and every successor n' generated by an action with step cost c(n, a, n'), the estimated cost satisfies h(n) ≤ c(n, a, n') + h(n'). In plain terms, the heuristic's estimate can never drop by more than the actual cost of the step just taken. Consistency is a stronger condition than admissibility: every consistent heuristic is admissible, but not every admissible heuristic is consistent. Consistency matters practically because it guarantees that the f-values along any path A* explores are non-decreasing, which in turn guarantees that A* graph search (the version that also tracks a CLOSED list to avoid re-expanding nodes) finds the optimal solution the first time it reaches any given node, without ever needing to revisit and revise that node's cost later.

Time and Space Complexity

Formally bounding best-first search's performance requires two parameters: the branching factor b (the maximum number of successors any node can have) and the maximum solution depth or path length m (or d, when specifically referring to the depth of the shallowest goal).

  • Worst-case time complexity: O(b^m). In the worst case, a poorly informed heuristic provides no better guidance than blind search, so the algorithm may need to examine an exponential number of nodes just as Breadth-First Search would.
  • Worst-case space complexity: O(b^m), because every generated node may need to be held in the OPEN or CLOSED list simultaneously in the worst case. This is the single biggest practical limitation of best-first search family algorithms (including A*) on very large state spaces: memory, not time, is usually what runs out first.
  • Practical (average-case) behavior: With a well-designed, informative heuristic, both algorithms typically expand far fewer nodes than the worst-case bound suggests. The tighter the heuristic tracks the true remaining cost, the closer A* comes to only exploring nodes that lie on or very near the optimal path, a property sometimes summarized by saying A* is "optimally efficient" among admissible search algorithms that use the same heuristic information, meaning no other algorithm with access to the same h(n) is guaranteed to expand fewer nodes while still finding the optimal solution.

Because raw memory use is often the practical bottleneck, several memory-bounded variants exist in the research literature, including Iterative Deepening A* (IDA*), Simplified Memory-Bounded A* (SMA*), and, for the specific weaknesses of greedy best-first search under certain heuristic conditions, algorithms explored in academic work such as Heusner, Keller, and Helmert's analysis of greedy best-first search's search behavior, published at the 2017 Symposium on Combinatorial Search and extended in a 2018 IJCAI paper on the best-case and worst-case behavior of the algorithm.

Comparison Table: Best First Search vs BFS, DFS, Dijkstra, and A*

AlgorithmUses a Heuristic?Evaluation FunctionComplete?Optimal?Typical Use Case
Breadth-First Search (BFS)No (uninformed)Expansion order = insertion order (FIFO queue)YesYes, if all step costs are equalShortest path by number of edges; small/unweighted graphs
Depth-First Search (DFS)No (uninformed)Expansion order = most recently added (LIFO stack)Only on finite graphsNoMemory-constrained search; exploring deep structures like trees
Dijkstra's Algorithm / Uniform Cost SearchNo (h(n) = 0)f(n) = g(n)YesYes, with non-negative edge weightsShortest weighted path with no heuristic available
Greedy Best First SearchYesf(n) = h(n)Yes, on finite graphsNoFast, "good enough" pathfinding where speed matters more than optimality
A* SearchYesf(n) = g(n) + h(n)YesYes, if h(n) is admissibleGPS routing, robotics, game AI where an optimal path is required

Advantages and Disadvantages

Advantages

  • Generally much faster in practice than uninformed search strategies like BFS or DFS, because the heuristic actively steers the search toward the goal instead of exploring blindly.
  • Flexible: by simply changing the definition of f(n), the same underlying algorithm produces Greedy Best First Search, A*, or Uniform Cost Search, making it a unifying framework rather than one rigid procedure.
  • When paired with an admissible heuristic (A* specifically), the algorithm is guaranteed to return the optimal solution, combining speed with a correctness guarantee that pure greedy methods cannot offer.
  • Well suited to large, weighted graphs, such as road networks or game maps, where uninformed search would be computationally impractical.

Disadvantages

  • Worst-case time and space complexity remain exponential, O(b^m), so performance depends heavily on how good the heuristic actually is; a poor or uninformative heuristic can degrade performance close to uninformed search.
  • Greedy Best First Search specifically is not optimal and is not even guaranteed to find a solution efficiently if the heuristic is misleading, since it can be drawn toward a dead end that merely looks close to the goal.
  • Designing a good heuristic function is itself a nontrivial engineering problem; a heuristic that is too loose provides little guidance, while one that is not admissible breaks A*'s optimality guarantee entirely.
  • Memory consumption can become the practical limiting factor before time does, since both OPEN and CLOSED lists must be kept for the duration of the search on large state spaces.

Real-World Applications

Best-first search algorithms, especially A* and its many derivatives, underpin a wide range of production systems that most people interact with regularly:

  • GPS and navigation systems: Modern mapping services run best-first search variants over road networks containing hundreds of millions of nodes, with heuristics that combine straight-line distance with historical traffic patterns, road classifications, and live conditions to compute routes across continental-scale graphs in real time.
  • Video game AI: Non-player characters in strategy games and role-playing games commonly use A* or a variant to navigate game maps, with heuristics blending geometric distance and terrain cost so characters prefer roads or open ground over difficult terrain.
  • Robotics and autonomous vehicles: Robots plan movement through configuration space, the abstract space representing all possible positions and orientations of the robot, using best-first search to find collision-free paths while estimating physical distance to a target configuration.
  • Puzzle solving: Classic AI puzzles such as the 8-puzzle and 15-puzzle are standard benchmarks for evaluating best-first search and A* heuristics (e.g., counting misplaced tiles, or summing Manhattan distances of each tile from its goal position).
  • Logistics, scheduling, and planning: Warehouse robotics and automated planning systems apply heuristic search to sequence tasks or movements efficiently while avoiding collisions and dead ends.

For professionals building toward roles that involve designing or evaluating these systems, understanding classical search algorithms is typically a prerequisite before moving into modern machine learning and generative AI techniques; Simpliaxis's guide on how to become an AI engineer outlines where foundational algorithms like this fit into a broader AI career roadmap, and learners often pair that theoretical grounding with a structured Introduction to AI and Machine Learning course before progressing to applied data science work such as Simpliaxis's Data Science with Python certification training.

Implementation Notes and Common Mistakes

  • Tree search vs graph search: A tree-search implementation of best-first search (no CLOSED list, no duplicate checking) can re-expand the same state repeatedly on graphs with cycles, wasting time or even failing to terminate. Graph search, which checks whether a state has already been reached, is almost always the correct choice for real-world state spaces.
  • Updating costs on rediscovery: If a node already in OPEN is reached again via a cheaper path, its stored cost and parent pointer must be updated (and its position in the priority queue re-adjusted); skipping this step is a common bug that silently breaks A*'s optimality guarantee.
  • Heuristic must match the problem's cost units: If g(n) is measured in kilometers but h(n) is estimated in some unrelated unit (or in a different distance metric that isn't a true lower bound), the sum f(n) = g(n) + h(n) becomes meaningless, and A*'s guarantees no longer hold.
  • Ties in the priority queue: Many implementations break ties between equal f-values by preferring nodes with a higher g-value (i.e., nodes deeper into the search), which in practice reduces the number of nodes expanded, since it favors making progress toward the goal over hovering near the start.
  • Verifying admissibility before trusting optimality: Before claiming an implementation of A* returns optimal paths, confirm the specific heuristic in use is genuinely admissible for that problem; a heuristic that works for one cost model (e.g., pure distance) may silently stop being admissible if the cost model changes (e.g., adding time penalties for turns or traffic).

Key Takeaways

  • Best First Search is a family of informed search algorithms that expand the frontier node with the best evaluation function score f(n), using a priority queue rather than a plain FIFO or LIFO structure.
  • Greedy Best First Search (f(n) = h(n)) is fast but not optimal; A* Search (f(n) = g(n) + h(n)) adds the accumulated path cost back into the decision and is optimal whenever the heuristic is admissible.
  • The theoretical guarantees behind A* rest on two heuristic properties: admissibility (never overestimating true cost) and the stronger property of consistency (estimates never drop by more than the actual step cost).
  • Worst-case time and space complexity for the whole family is O(b^m), but a well-designed heuristic routinely brings real-world performance far below that bound.
  • The Romania map example from Russell and Norvig's AIMA textbook remains the standard way to see, side by side, how greedy heuristic-only decisions can diverge from the truly optimal path that A* finds.
  • Best-first search variants, chiefly A*, power everyday systems including GPS navigation, video game pathfinding, and robotic motion planning, making this one of the most practically important algorithms taught in any foundational AI curriculum.

Schema Recommendation and Verification Notes

Schema recommendation: Implement Article structured data for the main content and FAQPage structured data for the Frequently Asked Questions section above, matching the questions and answers exactly as written.

Facts that could not be independently verified in this research pass: the exact 37% greedy-vs-A* speed differential figure sometimes cited in secondary sources was not traced to a specific, reproducible academic benchmark and is therefore omitted from the body of this article; readers should treat any specific speed-multiplier claims for greedy search versus A* as workload-dependent rather than universal. The precise founding date and authorship of the formal term "best-first search" as distinct from "Graph Traverser" is attributed here to the general historical record around Doran and Michie's 1966 paper, but this article does not claim that paper used the exact phrase "best-first search" itself, since that specific terminological detail could not be confirmed with full certainty from available sources during this research pass. All numeric straight-line-distance values in the Romania map table are drawn from the widely reproduced AIMA textbook example and should be verified against the current edition of Russell and Norvig's "Artificial Intelligence: A Modern Approach" if used in a context requiring textbook-level precision.

Frequently Asked Questions

No. Best First Search is the general family of algorithms that expand the frontier node judged best by an evaluation function f(n). A* is one specific member of that family, defined by f(n) = g(n) + h(n). Greedy Best First Search, defined by f(n) = h(n), is another member. All three (best-first search as a category, greedy best-first search, and A*) are related but not interchangeable terms.

On a finite graph, best-first search (in its graph-search form, with duplicate detection) is complete, meaning it will find a solution if one exists. On infinite state spaces, completeness is not guaranteed for Greedy Best First Search, since a misleading heuristic can send it down an infinite unproductive path; A* remains complete on any finite-branching-factor space with a finite solution.

Not in general. Greedy Best First Search is not optimal, since it ignores the cost already paid to reach a node. A* Search is optimal, but only when its heuristic function is admissible (never overestimates the true remaining cost to the goal).

Breadth-First Search is an uninformed algorithm that expands nodes level by level using a FIFO queue, with no knowledge of which nodes are closer to the goal. Best First Search is informed: it uses a heuristic function to prioritize which node in the frontier to expand next, which typically makes it far more efficient when a good heuristic is available, though it loses BFS's simple guarantee of finding the shortest path by edge count on unweighted graphs unless the heuristic and cost function are specifically designed to preserve that.

A good heuristic is admissible (never overestimates true remaining cost), ideally consistent (its estimates never decrease by more than the actual step cost along any edge), and as close as possible to the true remaining cost without exceeding it. The closer h(n) tracks h*(n), the fewer nodes the search needs to expand while still guaranteeing optimality under A*.

Because it only considers h(n) and ignores g(n) entirely, Greedy Best First Search commits to promising-looking paths immediately and never reconsiders whether an already-explored path might turn out cheaper overall. This lets it skip a large amount of the verification work A* performs, at the cost of sometimes returning a longer or more expensive path than the true optimum.

Yes. On an unweighted graph (or one where every action has equal cost), Uniform Cost Search, A*, and BFS with an admissible heuristic all tend to converge in behavior, since g(n) simply counts steps. Best-first search shows its distinct advantage most clearly on weighted graphs, where edge costs vary and a pure step-count metric like plain BFS would give misleading results.

Dijkstra's algorithm is mathematically equivalent to running best-first search with h(n) = 0 for every node, so that f(n) = g(n) alone. In the search-algorithms literature this special case is usually called Uniform Cost Search. Adding a non-zero, admissible heuristic on top of Uniform Cost Search is precisely what turns it into A* Search.
View More

About the Author

Labham Mishra

Labham Mishra

She is a professional content specialist with over three years of experience in the professional training and ed-tech industry. She specializes in creating well-researched, engaging, and informative content for certification courses, including PMP®, PRINCE2®, Scrum Master, Agile, ITIL®, Lean Six Sigma, DevOps, and Business Analysis. With a strong research-oriented approach and the ability to simplify complex concepts, she develops content that helps professionals gain practical knowledge and make informed career decisions. Her commitment to clarity, accuracy, and continuous learning enables her to create valuable content that resonates with learners worldwide.

Join the Discussion

Please provide a valid Name.
Please provide a valid Email Address.
Please provide a Comment.

✓ By providing your contact details you agreed to our Privacy Policy & Terms and Conditions.

Comment section

Related Articles

Request More Details

Our privacy policy © 2018-2026, Simpliaxis Solutions Private Limited. All Rights Reserved

Get coupon upto 60% off

favcon
favcon-2

Unlock your potential with a free study guide