# Search Algorithms in Artificial Intelligence (AI) | Uninformed & Informed Search Algorithms

Search algorithms in Artificial Intelligence (AI) are methods used to navigate problem spaces and find solutions, paths, or optimal outcomes. They play a critical role in various AI tasks such as planning, game playing, constraint satisfaction, and optimization problems.

Search algorithms can be classified as uninformed or informed, depending on whether they use domain-specific knowledge (heuristics) to guide the search. Uninformed search algorithms, like Depth-First Search and Breadth-First Search, traverse the search space without any additional information, while informed search algorithms, like A* Search, use heuristics to estimate the cost to reach the goal, potentially speeding up the search and finding more efficient solutions. The choice of a search algorithm depends on the problem domain, the available knowledge, and the desired trade-off between optimality, speed, and memory requirements.

## Properties of Search Algorithms

The performance and behavior of AI search algorithms can be characterized by several key properties. Here are some of the most important properties of search algorithms:

### Completeness

A search algorithm is considered complete if it is guaranteed to find a solution when one exists. Completeness depends on factors such as the search strategy, the problem space, and the algorithm’s ability to handle infinite branches or loops.

### Optimality

An algorithm is considered optimal if it is guaranteed to find the best or most cost-effective solution when one exists. Optimality depends on the search strategy, the problem space, and the use of heuristics or cost functions to guide the search.

### Time Complexity

Time complexity refers to the amount of time an algorithm takes to find a solution, usually measured in terms of the number of nodes expanded or the number of operations performed. The time complexity of a search algorithm depends on factors such as the search strategy, the problem space, and the algorithm’s efficiency in pruning or exploring the search space.

### Space Complexity

Space complexity refers to the amount of memory required by the algorithm during the search process, usually measured in terms of the maximum number of nodes stored in memory. Space complexity is influenced by the search strategy, the problem space, and the algorithm’s ability to manage memory efficiently.

### Admissibility

In the context of informed search algorithms, admissibility refers to the property of a heuristic function, where it never overestimates the true cost to reach the goal. When a heuristic is admissible, it ensures that an informed search algorithm, such as A* search, will find an optimal solution.

### Consistency (Monotonicity)

Consistency, also known as monotonicity, is another property of heuristic functions in informed search algorithms. A heuristic is considered consistent if the estimated cost of reaching the goal from the current node is always less than or equal to the cost of reaching any neighboring node plus the estimated cost from that neighbor to the goal. Consistency ensures that an informed search algorithm, like A* search, will find an optimal solution and expand fewer nodes.

### Exploration vs. Exploitation

This property refers to the balance between exploring unknown parts of the search space and exploiting known information to guide the search towards the goal. Algorithms that favor exploration may be slower but more likely to find optimal solutions, while algorithms that favor exploitation may be faster but more prone to getting stuck in local minima.

Understanding and considering these properties when selecting a search algorithm can help ensure that the chosen method meets the requirements of a specific problem domain and leads to efficient, accurate, and reliable solutions.

## Search Algorithms in Artificial Intelligence

In AI, search algorithms can be broadly categorized into two types: informed and uninformed search algorithms. These algorithms are used to navigate problem spaces, find solutions, or optimize outcomes in various AI tasks.

### Uninformed Search Algorithms

Uninformed search algorithms, also known as blind search algorithms, used for search space without using any domain-specific knowledge or heuristics. They do not have any information about the problem beyond its definition and the structure of the search space.

Uninformed search algorithms rely solely on the problem’s structure and the initial state to make decisions. Uninformed search algorithms are:

#### Breadth-first Search

Breadth-first search (BFS) is a search algorithm that traverses all the nodes at a given depth before moving on to the next depth level. It starts at the root node and traverse all of its neighboring nodes before moving on to the next depth level. BFS is guaranteed to find the shortest path between the starting node and any other reachable node in an unweighted graph. However, it can be memory-intensive for larger graphs due to the need to store all the visited nodes.

#### Depth-first Search

Depth-first search (DFS) traverses as far as possible along each branch before backtracking. It starts at the root node and traverse each of its neighboring nodes until it reaches a dead end, and then backtracks to the next branch. DFS is useful for exploring all possible solutions in a large space, but may not find the optimal solution in some cases.

#### Depth-limited Search

Depth-limited search (DLS) is a variant of depth-first search that limits the maximum depth of exploration. It stops exploring a branch when the maximum depth is reached, even if the solution has not been found. DLS is useful for exploring large spaces where the optimal solution is not required, but may miss the solution if it is beyond the maximum depth.

#### Iterative Deepening Depth-first Search

Iterative deepening depth-first search (IDDFS) is a variant of depth-first search that gradually increases the maximum depth of exploration until the solution is found. It starts with a maximum depth of 1 and increases the depth by 1 in each iteration until the solution is found. IDDFS combines the advantages of DFS and BFS by exploring all possible solutions in a large space while also finding the optimal solution.

#### Uniform Cost Search

Uniform cost search (UCS) algorithm searches the nodes with the lowest cost first. It starts at the root node and traverses each neighboring node in order of increasing cost. UCS is useful for finding the optimal solution in a weighted graph, where the cost of each edge represents a different weight.

#### Bidirectional Search

Bidirectional search is a search algorithm that starts from both the starting and ending nodes and searches towards the middle. It traverses all the neighboring nodes in both directions until they meet at a common node. Bidirectional search is useful for reducing the search space in large graphs, as it only searches the nodes that are likely to be on the optimal path.

**Uninformed algorithms are generally easy to implement but may be less efficient or suboptimal in finding solutions compared to informed search algorithms.**

### Informed Search Algorithms

Informed search algorithms, also known as heuristic search algorithms, use domain-specific knowledge or heuristics to guide the search process. Heuristics are estimates of the cost or effort required to reach the goal from a given state, helping the algorithm to prioritize certain paths or nodes that appear more promising.

Informed search algorithms can be more efficient and effective in finding solutions or optimal outcomes, as they use additional information to guide their decisions. Common informed search algorithms are:

#### Best First Search Algorithm (Greedy Search)

The Best First Search Algorithm, also known as Greedy Search, is a search algorithm that selects the node that is closest to the goal state based on a heuristic function. The heuristic function provides an estimate of the distance between the current node and the goal state. The algorithm searches the node with the lowest heuristic value first, without considering the actual cost of reaching that node. This can lead to finding a sub-optimal solution if the heuristic function is not well-designed, as the algorithm may prioritize exploring nodes that are not on the optimal path.

#### A* Search Algorithm

The A* Search Algorithm is an informed search algorithm that combines the advantages of both uniform cost search and best-first search. It uses a heuristic function to estimate the distance from the current node to the goal state, but also considers the actual cost of reaching that node. A* search algorithm evaluates each node based on the sum of the cost of reaching that node and the heuristic value of that node. It then searches the node with the lowest evaluation value first, which is expected to be the most promising node for finding the optimal solution. A* search algorithm is guaranteed to find the optimal solution if the heuristic function is admissible and consistent. An admissible heuristic function never overestimates the actual distance to the goal, and a consistent heuristic function satisfies the condition that the heuristic estimate from any node to the goal is not greater than the cost of getting to any neighboring node plus the heuristic estimate from that node to the goal.

These search algorithms represent different approaches for traversing and exploring problem spaces in AI. The choice of the algorithm depends on various factors such as memory requirements, speed, and the need for optimal solutions. Informed search algorithms like **A* Search** generally perform better when a suitable heuristic is available, while uninformed search algorithms like **DFS or BFS** can be used when no domain-specific knowledge is accessible.

**More to read**

- Artificial Intelligence Tutorial
- History of Artificial Intelligence
- 4 Types of Artificial Intelligence
- What is the purpose of Artificial Intelligence?
- Artificial and Robotics
- Benefits of Artificial Intelligence
- Intelligent Agents in AI
- Production System in AI
- Artificial Intelligence Vs. Machine Learning
- Artificial Intelligence Vs. Human Intelligence
- Artificial Intelligence Vs. Data Science
- Artificial Intelligence Vs. Computer Science
- What Artificial Intelligence Cannot Do?
- Importance of Artificial Intelligence
- How has Artificial Intelligence Impacted Society?
- Application of Artificial Intelligence in Robotics