Start here

How to read a search problem

Every algorithm on this site searches a problem built from the same handful of pieces. Learn these once, and every page β€” and the visualizer β€” makes sense.

STATE SPACE β€” all states + the actions between them 2 4 3 1 5 SA BCG START GOAL g5 Β· h4 Β· f9 Each circle is a node = a state Each arrow is an action (with a cost) g = cost so far Β· h = est. to goal Β· f = g + h
A tiny search problem, labelled. Reading left→right: start S, actions (arrows) with costs, states (circles), and goal G. Node C shows its g, h and f.

The vocabulary

State

A situation the problem can be in β€” for a trip, which airport you're at. All possible states together make up the state space.

Node

A state as it appears in the search, drawn as a circle. As the rule goes: β€œnodes are states; actions are the arrows between them.”

Action (edge / successor)

A move that takes you from one state to another β€” a flight from one airport to the next. Each action has a cost.

Start & Goal

The initial state you begin from and the goal you're trying to reach. Checking β€œare we there yet?” is the goal test.

Path & cost

A sequence of actions from the start to a node. A path that reaches the goal is a solution; its cost is the sum of the action costs.

Expand

To open up a node and generate every state it can reach next (its neighbours / successors).

OPEN & CLOSED

OPEN (the frontier) = discovered but not yet expanded. CLOSED = already expanded. The order of CLOSED is the traversal.

g(n)

The cost so far β€” the real cost of the path from the start to node n.

h(n)

The heuristic β€” an estimate of the cost still to go from n to the goal. A smart guess, never exact.

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

A*'s evaluation function: cost already paid plus the estimated cost to go = the estimated total for a path through n. A* always expands the node with the smallest f.

πŸ’‘ g, h and f matter most for informed search (Greedy uses h; A* uses f = g + h). Uninformed search (BFS, DFS, UCS…) ignores h and just explores by rule.

Now you can read any of them

Pick an algorithm to see these pieces in action β€” with theory, a step-by-step gallery and a live run.

Browse the algorithms β†’