×

Uninformed Search Strategies - Artificial Intelligence

Breadth-first search (BFS)

It is a simple search strategy where the root node is expanded first, then covering all other successors of the root node, further move to expand the next level nodes and the search continues until the goal node is not found.

BFS expands the shallowest (i.e., not deep) node first using FIFO (First in first out) order. Thus, new nodes (i.e., children of a parent node) remain in the queue and old unexpanded node which are shallower than the new nodes, get expanded first.

In BFS, goal test (a test to check whether the current state is a goal state or not) is applied to each node at the time of its generation rather when it is selected for expansion.

Breadth-first search tree
Breadth-first search tree

In the above figure, it is seen that the nodes are expanded level by level starting from the root node A till the last node I in the tree. Therefore, the BFS sequence followed is: A->B->C->D->E->F->G->I.

BFS Algorithm

  • Set a variable NODE to the initial state, i.e., the root node.
  • Set a variable GOAL which contains the value of the goal state.
  • Loop each node by traversing level by level until the goal state is not found.
  • While performing the looping, start removing the elements from the queue in FIFO order.
  • If the goal state is found, return goal state otherwise continue the search.

The performance measure of BFS is as follows:

  • Completeness: It is a complete strategy as it definitely finds the goal state.
  • Optimality: It gives an optimal solution if the cost of each node is same.
  • Space Complexity: The space complexity of BFS is O(bd), i.e., it requires a huge amount of memory. Here, b is the branching factor and d denotes the depth/level of the tree
  • Time Complexity: BFS consumes much time to reach the goal node for large instances.

Disadvantages of BFS

  • The biggest disadvantage of BFS is that it requires a lot of memory space, therefore it is a memory bounded strategy.
  • BFS is time taking search strategy because it expands the nodes breadthwise.

Note: BFS expands the nodes level by level, i.e., breadthwise, therefore it is also known as a Level search technique.

Unlike BFS, this uninformed search explores nodes based on their path cost from the root node. It expands a node n having the lowest path cost g(n), where g(n) is the total cost from a root node to node n. Uniform-cost search is significantly different from the breadth-first search because of the following two reasons:

  • First, the goal test is applied to a node only when it is selected for expansion not when it is first generated because the first goal node which is generated may be on a suboptimal path.
  • Secondly, a goal test is added to a node, only when a better/ optimal path is found.

Thus, uniform-cost search expands nodes in a sequence of their optimal path cost because before exploring any node, it searches the optimal path. Also, the step cost is positive so, paths never get shorter when a new node is added in the search.

Uniform-cost search on a binary tree

Uniform-cost search on a binary tree

In the above figure, it is seen that the goal-state is F and start/ initial state is A. There are three paths available to reach the goal node. We need to select an optimal path which may give the lowest total cost g(n). Therefore, A->B->E->F gives the optimal path cost i.e., 0+1+3+4=8.

Uniform-cost search Algorithm

  • Set a variable NODE to the initial state, i.e., the root node and expand it.
  • After expanding the root node, select one node having the lowest path cost and expand it further. Remember, the selection of the node should give an optimal path cost.
  • If the goal node is searched with optimal value, return goal state, else carry on the search.

The performance measure of Uniform-cost search

  • Completeness: It guarantees to reach the goal state.
  • Optimality:  It gives optimal path cost solution for the search.
  • Space and time complexity: The worst space and time complexity of the uniform-cost search is O(b1+LC*/??).

Note: When the path cost is same for all the nodes, it behaves similar to BFS.

  • It does not care about the number of steps a path has taken to reach the goal state.
  • It may stick to an infinite loop if there is a path with infinite zero cost sequence.
  • It works hard as it examines each node in search of lowest cost path.

This search strategy explores the deepest node first, then backtracks to explore other nodes. It uses LIFO (Last in First Out) order, which is based on the stack, in order to expand the unexpanded nodes in the search tree. The search proceeds to the deepest level of the tree where it has no successors. This search expands nodes till infinity, i.e.,  the depth of the tree.

Depth-first search

DFS search tree

In the above figure, DFS works starting from the initial node A (root node) and traversing in one direction deeply till node I and then backtrack to B and so on. Therefore,  the sequence will be A->B->D->I->E->C->F->G.

DFS Algorithm

  • Set a variable NODE to the initial state, i.e., the root node.
  • Set a variable GOAL which contains the value of the goal state.
  • Loop each node by traversing deeply in one direction/path in search of the goal node.
  • While performing the looping, start removing the elements from the stack in LIFO order.
  • If the goal state is found, return goal state otherwise backtrack to expand nodes in other direction.

The performance measure of DFS

  • Completeness: DFS does not guarantee to reach the goal state.
  • Optimality: It does not give an optimal solution as it expands nodes in one direction deeply.
  • Space complexity: It needs to store only a single path from the root node to the leaf node. Therefore, DFS has O(bm) space complexity where b is the branching factor(i.e., total no. of child nodes, a parent node have) and m is the maximum length of any path.
  • Time complexity: DFS has O(bm) time complexity.

Disadvantages of DFS

  • It may get trapped in an infinite loop.
  • It is also possible that it may not reach the goal state.
  • DFS does not give an optimal solution.

Note: DFS uses the concept of backtracking to explore each node in a search tree.

This search strategy is similar to DFS with a little difference. The difference is that in depth-limited search, we limit the search by imposing a depth limit l to the depth of the search tree. It does not need to explore till infinity. As a result, the depth-first search is a special case of depth-limited search. when the limit l is infinite.

Depth-limited search on a binary tree

Depth-limited search on a binary tree

In the above figure, the depth-limit is 1. So, only level 0 and 1 get expanded in A->B->C DFS sequence, starting from the root node A till node B. It is not giving satisfactory result because we could not reach the goal node I.

Depth-limited search Algorithm

  • Set a variable NODE to the initial state, i.e., the root node.
  • Set a variable GOAL which contains the value of the goal state.
  • Set a variable LIMIT which carries a depth-limit value.
  • Loop each node by traversing in DFS manner till the depth-limit value.
  • While performing the looping, start removing the elements from the stack in LIFO order.
  • If the goal state is found, return goal state. Else terminate the search.

The performance measure of Depth-limited search          

  • Completeness: Depth-limited search does not guarantee to reach the goal node.
  • Optimality: It does not give an optimal solution as it expands the nodes till the depth-limit.
  • Space Complexity: The space complexity of the depth-limited search is O(bl).
  • Time Complexity: The time complexity of the depth-limited search is O(bl).
  • This search strategy is not complete.
  • It does not provide an optimal solution.

Note: Depth-limit search terminates with two kinds of failures: the standard failure value indicates “no solution," and cut-off value, which indicates “no solution within the depth-limit."

This search is a combination of BFS and DFS, as BFS guarantees to reach the goal node and DFS occupies less memory space. Therefore, iterative deepening search combines these two advantages of BFS and DFS to reach the goal node. It gradually increases the depth-limit from 0,1,2 and so on and reach the goal node.

Iterative deepening depth-first search/Iterative deepening search

In the above figure, the goal node is H and initial depth-limit =[0-1]. So, it will expand level 0 and 1 and will terminate with A->B->C sequence. Further, change the depth-limit =[0-3], it will again expand the nodes from level 0 till level 3 and the search terminate with A->B->D->F->E->H sequence where H is the desired goal node.

Iterative deepening search Algorithm

  • Explore the nodes in DFS order.
  • Set a LIMIT variable with a limit value.
  • Loop each node up to the limit value and further increase the limit value accordingly.
  • Terminate the search when the goal state is found.

The performance measure of Iterative deepening search

  • Completeness: Iterative deepening search may or may not reach the goal state.
  • Optimality: It does not give an optimal solution always.
  • Space Complexity: It has the same space complexity as BFS, i.e., O(bd).
  • Time Complexity: It has O(d) time complexity.

Disadvantages of Iterative deepening search

  • The drawback of iterative deepening search is that it seems wasteful because it generates states multiple times.

Note: Generally, iterative deepening search is required when the search space is large, and the depth of the solution is unknown.

The strategy behind the bidirectional search is to run two searches simultaneously--one forward search from the initial state and other from the backside of the goal--hoping that both searches will meet in the middle. As soon as the two searches intersect one another, the bidirectional search terminates with the goal node. This search is implemented by replacing the goal test to check if the two searches intersect. Because if they do so, it means a solution is found.

The performance measure of Bidirectional search

  • Complete: Bidirectional search is complete.
  • Optimal: It gives an optimal solution.
  • Time and space complexity: Bidirectional search has O(bd/2)
  • It requires a lot of memory space.

Related Topics

Informed Search/ Heuristic Search in AI

An informed search is more efficient than an uninformed search because in informed search, along with the current state information,  some additional information is also present, which make it easy to reach the...

6 minutes read.

Minimax Strategy

In artificial intelligence, minimax is a decision-making strategy under game theory, which is used to minimize the losing chances in a game and to maximize the winning chances. This strategy is also known...

3 minutes read.

Natural Language Processing

Natural Language Processing in AI Topics Covered in Language Module Natural Language ProcessingSyntax and SemanticsContext-Free GrammarNLTKN-gramsTokenizationBag of WordsNaïve Bayes In language, we will cover how Artificial Intelligence is used to process human language...

13 minutes read.

Inference Rules in Proposition Logic

Inference rules are those rules which are used to describe certain conclusions. The inferred conclusions lead to the desired goal state. In propositional logic, there are various inference rules which can be applied to...

3 minutes read.

Probabilistic Reasoning

Probabilistic Reasoning Probabilistic Reasoning is the study of building network models which can reason under uncertainty, following the principles of probability theory. Bayesian Networks Bayesian network is a data structure which is used to represent the dependencies among variables....

7 minutes read.

Integration of Blockchain and Artificial Intelligence

A Blockchain is a shared database or ledger where pieces of data are stored in data structures known as blocks. So, we can say that Blockchain is the distribution storage...

6 minutes read.

Inference in First-order Logic

Inference in First-order Logic While defining inference, we mean to define effective procedures for answering questions in FOPL. FOPL offers the following inference rules: Inference rules for quantifiersUniversal Instantiation (UI): In this, we can infer any sentence by...

5 minutes read.

Utility Functions in Artificial Intelligence

The agents use the utility theory for making decisions. It is the mapping from lotteries to the real numbers. An agent is supposed to have various preferences and can choose the one...

3 minutes read.

Propositional Logic

It is a branch of logic which is also known as statement logic, sentential logic, zeroth-order logic, and many more. It works with the propositions and its logical connectivities. It deals with the...

5 minutes read.

Unsupervised Learning in AI

Unsupervised Learning in AI Unsupervised LearningIntroductionClusteringComparison between Supervised, Unsupervised, and Reinforcement Learning. Unsupervised Learning This is the third major category of Machine Learning. Unsupervised learning happens when we have data without additional feedback,...

2 minutes read.

Top 7 Artificial Intelligence and Machine Learning trends for 2024

Artificial Intelligence is the ability of machines to perform the same function as human beings, like problem-solving, learning, reasoning and recognizing. Machine Learning is another branch of Computer Science and...

6 minutes read.

Heuristic Functions in Artificial Intelligence

Heuristic Functions in AI: As we have already seen that an informed search make use of heuristic functions in order to reach the goal node in a more prominent way....

3 minutes read.

Dynamic Routing

Dynamic Routing Dynamic routing is used to update the routing table and find networks on the routers. It is easier than static routing and default routing, but it is more expensive in terms of...

3 minutes read.

Quantifying Uncertainty

The concept of quantifying uncertainty relies on how an agent can keep away uncertainty with a degree of belief. The term uncertainty refers to that situation or information which is either unknown or...

5 minutes read.

Intelligent Agents | Agents in AI

What is an Agent? An agent can be viewed as anything that perceives its environment through sensors and acts upon that environment through actuators. For example, human being perceives their surroundings through...

8 minutes read.

Knowledge Representation in AI

In this section, we will understand how to represent the knowledge in the form which could be understood by the knowledge-based agents. The knowledge that is stored in the system is related to...

5 minutes read.

Information Retrieval

Information Retrieval: In order to analyze and categorize the text, we'd like to be able to figure out information about the text, some meaning about the text as well. And,...

14 minutes read.

Resolution Method in AI

Resolution Method in AI Resolution method is an inference rule which is used in both Propositional as well as First-order Predicate Logic in different ways. This method is basically used for proving the...

5 minutes read.

Hidden Markov Models

Hidden Markov Model is a partially observable model, where the agent partially observes the states. This model is based on the statistical Markov model, where a system being modeled follows the Markov process...

4 minutes read.

Local Search Algorithms and Optimization Problem

The informed and uninformed search expands the nodes systematically in two ways: keeping different paths in the memory and selecting the best suitable path, Which leads to a solution state required to reach the goal...

2 minutes read.