Iterative Deepening A* algorithm (IDA*) in Artificial intelligence (original) (raw)

Last Updated : 23 Jul, 2025

_Iterative deepening A (IDA)** is a powerful graph traversal and pathfinding algorithm designed to find the **shortest path in a weighted graph. This method combines features of **iterative deepening depth-first search (IDDFS) and the _A search algorithm* by using a heuristic function to estimate the remaining cost to the goal node. IDA* is often referred to as a **memory-efficient version of A*, as it requires significantly less memory while still ensuring optimal pathfinding.

**This article aims to explain how the Iterative Deepening A* (IDA*) algorithm efficiently finds the shortest path in a weighted graph while using minimal memory.

Table of Content

What is the Iterative Deepening A* (IDA*) Algorithm?

IDA* is a variant of depth-first search (DFS) that iteratively deepens its search by incrementing the cost threshold, which controls the depth of the exploration. Unlike A*, which explores all possible nodes within a threshold, IDA* uses a heuristic function to evaluate and prioritize the most promising nodes. This allows it to prune less promising paths, reducing memory usage while ensuring that the search focuses on optimal routes.

Key Features of IDA* Algorithm

  1. **Graph Traversal Algorithm: IDA* explores a graph by progressively deepening the search depth.
  2. **Shortest Pathfinding: It efficiently finds the **shortest path in a weighted graph using a combination of DFS and A* techniques.
  3. **Admissible Heuristic: The heuristic function in IDA* ensures that the estimated cost never exceeds the actual cost, making it an **admissible heuristic.
  4. **Memory Efficiency: As a **depth-first search algorithm, IDA* uses far less memory compared to the traditional A* algorithm.
  5. **Focused Search: The algorithm is designed to explore **only the most promising nodes, ensuring it doesn’t go to unnecessary depths.

How the IDA* Algorithm Works?

The IDA* algorithm works by incrementally increasing the **threshold based on the f-score of each node, which is calculated using the formula:

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

f(n) = \text{Actual\;cost} + \text{Estimated \; cost}

Where **h is admissible.

Here,

What is the F-score?

In the IDA* algorithm, F-score is a **heuristic function that is used to estimate the cost of reaching the goal state from a given state. It is a combination of two other heuristic functions, g(n) and **h(n).
It is used to determine the order in which the algorithm expands nodes in the search tree and thus, it plays an important role in how quickly the algorithm finds a solution.

A lower F-score indicates that a node is closer to the goal state and will be expanded before a node with a higher F-score. Simply it is nothing but **g(n) + h(n).

Step-by-Step Process of the IDA* Algorithm

  1. **Initialization: Set the root node as the current node and compute its f-score.
  2. **Set Threshold: Initialize a threshold based on the f-score of the starting node.
  3. **Node Expansion: Expand the current node’s children and calculate their f-scores.
  4. **Pruning: If the f-score exceeds the threshold, prune the node and store it for future exploration.
  5. **Path Return: Once the goal node is found, return the path from the start node to the goal.
  6. **Update Threshold: If the goal is not found, increase the threshold based on the minimum pruned value and repeat the process.

Example of IDA* Algorithm

In the below tree, the f score is written inside the nodes means the f score is already computed and the start node is **2 whereas the goal node is **15. the explored node is colored green color.

So now we have to go to a given goal by using IDA* algorithm.

Iteration 1

Iteration 1

Iteration 2

Iteration 2

Iteration 3

Iteration 3

Iteration 4

Iteration 5

Iteration 6

Iteration 6

Real-World Applications of IDA*

1. The 15-Puzzle Problem

The 15-puzzle problem is a classic example of a **sliding puzzle game. It consists of a 4x4 grid of numbered tiles with one tile missing. The aim is to rearrange the tiles to form a specific goal configuration. The state space of the puzzle can be represented as a tree where each node represents a configuration of the puzzle and each edge represents a legal move. IDA* can be used to find the **shortest sequence of moves to reach the goal state from the initial state.

2. The 8-Queens Problem

The 8-Queens problem is a classic example of the n-Queens problem where n queens have been placed on an n x n chessboard such that no two queens attack each other. The state space of the problem can be represented as a tree where each node represents a configuration of the chessboard and each edge represents the placement of a queen. IDA* can be used to find the **minimum number of queens that need to be moved to reach the goal state.

In both of these examples, IDA* is used to find the optimal solution by using a combination of depth-first search and a heuristic function to limit the search space. The algorithm incrementally increases the depth bound, allowing it to find the solution without exploring the entire state space, which would be infeasible for larger problems.

Advantages and Disadvantages of Iterative Deepening A* algorithm (IDA*)

Advantages

  1. **Optimal Pathfinding: IDA* guarantees finding the optimal path, as it never overestimates the cost to the goal.
  2. **Memory Efficient: It uses **limited memory compared to A* by applying depth-first search techniques.
  3. **Admissible Heuristic: The heuristic function ensures that the algorithm remains admissible, thus optimizing performance.
  4. **Efficient with Large State Spaces: IDA* handles large graphs efficiently by pruning unnecessary nodes.

Disadvantages

  1. **Repeated Node Exploration: The algorithm does not store visited nodes, leading to repeated exploration.
  2. **Slower than A*: IDA* can be slower than algorithms like A* due to the repeated exploration of nodes.
  3. **Higher Computational Cost: It may take longer and consume more processing power compared to other algorithms like A* or breadth-first search.

It's important to note that IDA* is not suitable for all types of problems, and the choice of algorithm will depend on the specific characteristics of the problem you're trying to solve.

IDA* vs Iterative Deepening Depth-First Search (IDDFS)

The table given below highlights the differences between IDA* and Iterative Deepening Depth-First Search (IDDFS):

**Criteria **Iterative Deepening Depth-First Search (IDDFS) _Iterative Deepening A (IDA)**
**Systematic Systematic exploration of the search space. Not systematic; may revisit nodes due to threshold updates.
**Optimality Guarantees optimal solution in unweighted graphs. Optimal, but only expands nodes where f-score ≤ threshold.
**Node Expansion Never expands the same node twice. May expand the same node multiple times if f-score < threshold.
**Handling Infinite Search Traversal Not suited for infinite search traversal. Better suited for infinite search traversal compared to IDDFS.

Applications of IDA* in Artificial intelligence

IDA* is particularly suited for solving complex AI problems where memory is limited. Here are a few areas where it is commonly applied:

  1. **Pathfinding in Games: IDA* is frequently used in video games where memory is a constraint, and optimal paths need to be found efficiently, such as in real-time strategy games.
  2. **Robot Navigation: In robotics, IDA* is applied to efficiently navigate through complex environments without requiring excessive memory.
  3. **Puzzle Solving: Classic AI problems like the 8-puzzle or 15-puzzle can be solved using IDA*, where the search space is large and memory constraints are significant.
  4. **Artificial General Intelligence (AGI): In research areas exploring AGI, where problem-solving often involves navigating vast search spaces, IDA* can be used to manage memory while finding optimal solutions.

Conclusion

The _Iterative Deepening A (IDA*) algorithm* strikes a balance between **memory efficiency and **optimal pathfinding by combining the strengths of depth-first search and heuristic functions. It prunes unpromising paths, allowing it to handle larger state spaces than traditional algorithms. While IDA* might not be the fastest option, its ability to find the optimal solution while using less memory makes it an excellent choice for solving problems like the **15-puzzle and **n-Queens problems. It’s a robust solution for **graph traversal and **pathfinding when memory efficiency is a concern.