Uninformed Search Algorithms
Uninformed Search Algorithms
Uninformed search, also known as blind search, is a search algorithm that explores a problem
space without any specific knowledge or information about the problem other than the initial state
and the possible actions to take. It lacks domain-specific heuristics or prior knowledge about the
problem. Uninformed search algorithms, such as breadth-first search and depth-first search,
systematically explore the search space by applying predefined rules to generate successor states
until a goal state is found or the search is exhausted. These algorithms are typically less efficient
than informed search algorithms but can be useful in certain scenarios or as a basis for more
It is a search algorithm where the search tree will be traversed from the root node. It will be
traversing, searching for a key at the leaf of a particular branch. If the key is not found, the searcher
retraces its steps back (backtracking) to the point from where the other branch was left unexplored,
root node A and then goes to the branch where node B is present (lexicographical order). Then it
goes to node D because of DFS, and from D, there is only one node to traverse, i.e., node H. But
after node H does not have any child nodes, we retrace the path in which we traversed earlier and
again reach node B, but this time, we traverse through in the untraced path a traverse through node
E. There are two branches at node E, but let’s traverse node I (lexicographical order) and then
retrace the path as we have no further number of nodes after E to traverse. Then we traverse node
J as it is the untraced branch and then again find we are at the end and retrace the path and reach
node B and then we will traverse the untraced branch, i.e., through node C, and repeat the same
DFS requires very little memory as it only needs to store a stack of the nodes on the path from the
root node to the current node.
It takes less time to reach the goal node than the BFS algorithm [which is explained later](if it
traverses in the right path).
Disadvantages
There is the possibility that many states keep reoccurring, and there is no guarantee of finding a
solution.
The DFS algorithm goes for deep-down searching, and sometimes it may go to the infinite loop.
This is another graph search algorithm in AI that traverses breadthwise to search for the goal in a
tree. It begins searching from the root node and expands the successor node before expanding
further along breadthwise and traversing those nodes rather than searching depth-wise.
The above figure is an example of a BFS Algorithm. It starts from the root node A and then
traverses node B. Till this step, it is the same as DFS. But here, instead of expanding the children
of B as in the case of DFS, we expand the other child of A, i.e., node C because of BFS, and then
move to the next level and traverse from D to G and then from H to K in this typical example. To
traverse here, we have only taken into consideration the lexicographical order. This is how the
BFS Algorithm is implemented.
Advantages
Disadvantages
• It requires lots of memory since each level of the tree must be saved in memory to expand
to the next level.
• BFS needs lots of time if the solution is far away from the root node.
Difference
Using It uses knowledge for the searching It doesn’t use knowledge for the
Knowledge process. searching process.
Size of search Having a wide scope in terms of Solving a massive search task is
problems handling large search problems. challenging.
Parameters Informed Search Uninformed Search
BFS example
Suppose we have a search space with an initial state "A" and a goal state "E" connected by
nodes as follows:
A
/\
B C
/\
D E
To perform BFS on this search space, we start by adding the initial state "A" to a queue:
Queue: A
Explored: {}
We dequeue the first node in the queue, which is "A", and add its children "B" and "C" to the
end of the queue:
Queue: B, C
Explored: {A}
We then dequeue "B" and "C" and add their children to the end of the queue:
Queue: C, D
Explored: {A, B}
We dequeue "C" and add its child "E" to the end of the queue:
Queue: D, E
Explored: {A, B, C}
Finally, we dequeue "D" and "E" and find that "E" is the goal state, so we have successfully
found a path from "A" to "E" using BFS.
DFS Example
Example
Traversing a binary tree
1
/ \
2 3
/ \ / \
4 5 6 7
To traverse this tree using DFS, we start at the root node (1) and explore as far as possible along
each branch before backtracking. Here is the order in which the nodes would be visited.
We first visit the root node (1), then the left child (2), and so on. Once we reach a leaf node (4),
we backtrack to the last node with an unexplored child (2) and continue exploring its other child
(5). We continue this process until all nodes have been visited.
Example2 DFS
Step 1: Create a stack with the total number of vertices in the graph as the size.
Step 2: Choose any vertex as the traversal's beginning point. Push a visit to that vertex
and add it to the stack.
Step 3 - Push any non-visited adjacent vertices of a vertex at the top of the stack to the
top of the stack.
Step 4 - Repeat steps 3 and 4 until there are no more vertices to visit from the vertex at
the top of the stack.
Step 5 - If there are no new vertices to visit, go back and pop one from the stack using
backtracking.
Step 7 - When the stack is entirely unoccupied, create the final spanning tree by
deleting the graph's unused edges.
Consider the following graph as an example of how to use the dfs algorithm.
Step 3: From vertex C and D, visit any adjacent unvisited vertices of vertex B. Imagine
you have chosen vertex C, and you want to make C a visited vertex.
Step 6: Vertex E's nearby vertices, namely vertex C and D have been visited, pop
vertex E from the stack.
Step 7: Now that all of vertex D's nearby vertices, namely vertex B and C, have been
visited, pop vertex D from the stack.
Step 8: Similarly, vertex C's adjacent vertices have already been visited; therefore, pop
it from the stack.
Step 9: There is no more unvisited adjacent vertex of b, thus pop it from the stack.
Step 10: All of the nearby vertices of Vertex A, B, and C, have already been visited, so
pop vertex A from the stack as well.