Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Unit 1 — Best-First Search Technique

Lesson 12 of 34 in the free Artificial Intelligence notes on Siksha Sarovar, written by Rohit Jangra.

Best-First Search Technique

Best-first search combines the systematic bookkeeping of breadth-first/depth-first search with the guidance of a heuristic: at every step it expands the node in the frontier that currently looks most promising, regardless of where in the tree it lies.

OPEN and CLOSED Lists

ListContents
OPENNodes generated but not yet expanded, ordered by heuristic value (best first)
CLOSEDNodes already expanded (visited), kept to avoid re-expanding them

Algorithm

1. Put the initial state on OPEN.
2. If OPEN is empty, fail.
3. Remove from OPEN the node n with the best heuristic value; put n on CLOSED.
4. If n is a goal state, return the path to n and stop.
5. Expand n, generating its successors. For each successor:
   - If not already on OPEN or CLOSED, compute its heuristic value and add to OPEN.
   - If already on OPEN/CLOSED with a worse path, update it with the better path found.
6. Sort OPEN by heuristic value (or insert in sorted position).
7. Go to step 2.

A* Search — Best-First With a Guarantee

**A-star (A)* is the most important best-first algorithm. It evaluates each node n using:

f(n) = g(n) + h(n)

TermMeaning
g(n)Actual cost from the initial state to n (known, exact)
h(n)Estimated (heuristic) cost from n to the nearest goal
f(n)Estimated total cost of the cheapest solution path through n

Admissibility: if h(n) never overestimates the true remaining cost (h(n) is less than or equal to the true cost to goal, for every n), A* is guaranteed to find an optimal solution.

AlgorithmUses g(n)?Uses h(n)?Optimal?
Breadth-First SearchImplicitly (uniform cost)NoYes (if costs equal)
Greedy Best-First SearchNoYes onlyNo
**A-star (A)*YesYesYes, if h is admissible

Worked Mini-Example (8-Puzzle)

A common admissible heuristic for the 8-puzzle is h = number of misplaced tiles, or the stronger h = sum of Manhattan distances of each tile from its goal position. A* using Manhattan distance expands far fewer nodes than blind BFS because f(n) actively steers the search toward the goal.

Strengths and Weaknesses

StrengthsWeaknesses
Combines the best of BFS (systematic) and greedy search (guided)OPEN list can grow very large — memory is the main bottleneck
A* is optimal and complete with an admissible heuristicPerformance is only as good as the heuristic function
Widely used in pathfinding, robotics, gamesSorting OPEN by f(n) on every step adds overhead vs. a simple stack/queue