Search Algorithms in AI

Last Updated : 9 Jun, 2026

Search algorithms in AI are techniques used to find solutions by exploring possible paths or states in a problem space. They help intelligent systems make decisions, solve problems and reach goals efficiently in applications such as navigation, robotics, game playing and pathfinding.

  • Helps AI systems determine the best possible solution among multiple choices
  • Widely used in decision-making, optimization and route-planning problems

Types of Search Algorithms

There are mainly 2 types of search algorithms i.e Uninformed Search Algorithms and Informed Search Algorithms.

Search-Algorithms
Search Algorithms in AI

Uninformed Search Algorithms

Uninformed search, also known as blind search algorithms, explore the search space without using any domain specific knowledge about the goal state. They rely only on the structure of the problem such as node depth or path cost to decide which node to explore next.

Depth First Search explores nodes by moving as deep as possible along a branch before backtracking. It uses a stack or recursion to keep track of visited nodes.

  • Memory efficient because it stores fewer nodes compared to BFS
  • Does not always guarantee the shortest path
  • May get stuck in deep paths or cycles without proper checks

Example: DFS traversal from node S to G.

  • As DFS traverses the tree deepest node first it would always pick the deeper branch until it reaches the solution or it runs out of nodes and goes to the next branch.
  • Path: S → A → B → C → G

Breadth First Search explores all possible paths level by level starting from the root node. It visits all neighboring nodes before moving to the next depth level.

  • Guarantees the shortest path when all edge costs are equal
  • Complete search algorithm for finite graphs
  • Requires high memory because it stores all nodes at each level

Example: BFS traversal from node S to G

  • As BFS traverses the tree shallowest node first it would always pick the shallower branch until it reaches the solution or it runs out of nodes and goes to the next branch.
  • Path: S → D → G

Uniform Cost Search expands the node with the lowest cumulative path cost from the start node. It is useful when different paths have different traversal costs.

  • Finds the optimal path with minimum total cost
  • Uses a priority queue to select the lowest-cost node
  • Suitable for weighted graphs and navigation problems

Example: UCS traversal from node S to G

  • The cost of each node is the cumulative cost of reaching that node from the root and based on the UCS strategy the path with the least cumulative cost is chosen.
  • Path: S → A → B → G

Informed Search Algorithms

Informed search uses domain knowledge in the form of heuristics to make smarter decisions during the search process. These heuristics estimate how close a state is to the goal guiding the search more efficiently.

Greedy Search selects the node that appears closest to the goal based on the heuristic value h(n). It focuses only on the estimated distance to the goal and ignores the path cost already travelled.

  • Fast and memory efficient due to heuristic guidance
  • Does not always produce the optimal solution
  • Best suited when quick approximate solutions are acceptable

Example: We find the path from S to G using greedy search, the heuristic values h of each node below the name of the node. 

  • Starting from S we can traverse to A(h=9) or D(h=5). We choose D as it has the lower heuristic cost.
  • Now from D we can move to B(h=4) or E(h=3). We choose E with a lower heuristic cost.
  • Finally from E we go to G(h=0). This entire traversal is shown in the search tree below, in blue. 
  • Path: S → D → E → G

A* Tree Search uses an evaluation function to evaluate and prioritize nodes during the search process:

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

Where:

  • g(n) = actual cost from the start node
  • h(n) = estimated cost to the goal

This approach explores paths with the lowest combined cost but treats the search space as a tree, meaning repeated states are not tracked.

  • Combines actual path cost and heuristic cost
  • May revisit the same state multiple times
  • Simpler to implement but less efficient for graphs with cycles

Example: Find the path to reach from S to G using A* search. 

9

Starting from S the algorithm computes g(x) + h(x) for all nodes in the fringe at each step choosing the node with the lowest sum. The entire work is shown in the table below.

Pathh(x)g(x)f(x)
S707
    
S -> A9312
S -> D   ✔527
    
S -> D -> B   ✔42 + 1 = 37
S -> D -> E32 + 4 = 69
    
S -> D -> B -> C   ✔23 + 2 = 57
S -> D -> B -> E   ✔33 + 1 = 47
    
S -> D -> B -> C -> G05 + 4 = 99
S -> D -> B -> E -> G   ✔ 04 + 3 = 77

Path: S → D → B → E → G and Cost: 7

A* Graph Search improves upon A* Tree Search by keeping track of already visited nodes using a closed list. This avoids revisiting nodes and reduces redundant exploration.

  • Efficient for graphs containing cycles or repeated states
  • Guarantees the optimal path when the heuristic is admissible
  • Widely used in navigation systems, robotics and games

Example: Use graph searches to find paths from S to G in the following graph. 

  • We keep a track of nodes explored so that we don't re explore them. 
  • Path: S → D → B → E → G and Cost: 7 

Comparison of Different Search Algorithms

AlgorithmTime ComplexitySpace ComplexityCompleteOptimal
Breadth First Search

O(b^d)

O(b^d)

YesYes (if step cost is same)
Depth First Search

O(b^d)

O(d)

NoNo
Uniform Cost Search

O(b^{1 + \frac{C^*}{\epsilon}})

O(b^{1 + \frac{C^*}{\epsilon}})

YesYes
Greedy Search

O(b^m)

O(b^m)

NoNo
A* Tree Search

O(b^d)

O(b^d)

Yes (if h is admissible)Yes (if h is admissible)
A* Graph Search

O(b^d)

O(b^d)

Yes (if h is admissible)Yes (if h is admissible)

Advantages

  • Helps AI systems find optimal or near-optimal solutions
  • Useful in pathfinding, robotics, games and decision-making
  • Some algorithms guarantee shortest or lowest-cost paths
  • Heuristic-based methods improve efficiency and speed

Limitations

  • Some algorithms require large memory and computation time
  • Blind search methods can explore many unnecessary nodes
  • Heuristic quality directly affects informed search performance
  • Certain algorithms may not guarantee optimal solutions
  1. Artificial Intelligence (AI) Algorithms
  2. Informed Search Algorithms in Artificial Intelligence
  3. Difference between Informed and Uninformed Search in AI
  4. Uninformed Search Algorithms in AI
Comment