Академический Документы
Профессиональный Документы
Культура Документы
1
Aim: Implement BFS and DFS algorithm for route finding problem.
Objective:
Student will learn:
i)
Uninformed Search
ii)
Uninformed search methods belong to the category of methods that have no prior knowledge of the
problem. They are generally exhaustive methods that are brute force, searching all possible paths. Since
these methods work in the absence of any information, they are also referred to as blind search methods.
These methods can be understood by a very simple example. If would like to search a boy named
Ram in a school, with the number of classes from 1 to 10 and each class having two divisions then the
search would involve going to each and every class till the student named Ram, we are looking for, is
found. Since no information is available, we need to select certain strategy and expand the nodes (here,
the classes) in some predefined order. Bread first search and depth first search are two basic approaches
of expanding and visiting nodes in the absence of any knowledge.
Breadth First Search (BFS)
The search technique in BFS follows the shallow node approach. Here the basic idea is that across the
level of the tree, all the nodes are searched. Queue data structure is used to carry out the search, where
things happen on first in first out basis (FIFO).
Let us take an example of BFS, consider that A is the start state and D is the goal state (Figure 1.2).
A
B
C
D
Figure 1.2 Sample tree input for BFS
In BFS, The step-wise working for the following graph:
Queue
Check
A
Removed A, is it goal? No, add children. So, B and E are added.
BE
E
EC
C
CFG
FG
FGD
GD
Empty
2.
ii.
iii.
iv.
If not, get the next level nodes, i.e., nodes reachable from the parent and add to node-list.
A
B
C
D
Figure 1.4 Sample tree input for DFS.
Stack
Step 1:
Top
Top
A
Step 2:
Top
E
C
Top
E
Step 3:
Top
E
D
Top
E
Step 4:
Top
E
The depth first search algorithm is summarized as follows:
1.
2.
Route Finding
Route finding is defined in terms of specified locations and transition along links between them. Let us
consider airline travel planning problem. The objective is to arrive to a destination.
Initial state: Starting point of the journey
Goal state: Final destination
Operators/Actions: Flight from current location to reach the next location.
Advantages of DFS
Requires less memory than BFS since only need to remember the current path
If lucky, can find a solution without examining much of the state space
Advantages of BFS
Guaranteed to find a solution if one exists in addition, finds optimal (shortest) solution
first
It will not get lost in a blind alley (i.e., does not require backtracking or cycle checking)
Conclusion: BFS and DFS algorithm is implemented for route finding problem.