AI Assignment: Compare Breadth First Search and Depth First Search Algorithm ?
AI Assignment: Compare Breadth First Search and Depth First Search Algorithm ?
ue 29 : Explain artificial intelligence . Also discuss the areas where it can be used ?
Q
Compare Breadth first search and Depth first search algorithm ?
Ans : Artificial Intelligence - "Artificial Intelligence is the study of how to make computers do
thing which , at the moment people do better ."
Artificial Intelligence is concerned with
intelligent behaviour in artifacts . Intelligent behaviour in turn involves perception , reasoning ,
learning , communicating and acting in complex enviroment . Artificial Intelligence (AI) has one
of its long term goal the development of machines that can do these things as well as human
can or possibly even better .
To make intelligent system a lot of knowledge is required . So AI
systems need a lot of knowledge base . This knowledge base is stored in the form of some
symbols. To became enough smart AI system it is necessary to update knowledge frequently. A
problem may be solved by using huerestic search techniques. It process the knowledge and
reach on some best suit result depends on search algorithm .
1) Game Playing : Shannon's paper on chess playing program and chockers area considered
as landmarks in the area of computer game playing . Now a days a lot of automated games are
there .
2) Expert systems : A "knowledge engine " interviews experts in a certain domain and tries to
ebody their knowledge in a computer program for carrying out some tasks .
3) Fuzzy Logic : We take a different approach and briefly consider what happens if we make
fundamental changes to our idea of set membership and corresponding changes to our
definations of logical operations .
The motivation for fuzzy set is provided by the need to
represent such is provided by the need to represent such prepositions as :-
John is good boy .
John is very good boy .
Breadth first search is performed by exploring all nodes at a given depth before processing to all
next level . It means that all immediate children of nodes are explored before any of the
children's children are considered . Search tree generated by a BFS is given below :-
A
/\
B C
/ /\
D E F
Output : A, B, C, D, E, F
1. Create a variable called NODE - LIST and set it to the initial state .
2. Loop until the goal state is found or NODE-LIST is empty.
1. Remove the first element,say E , from the NODE-LIST .If NODE-LIST
was empty then quite.
2. For each way that each rule can match the state described in E do:
3. i) Apply the rule to generate a new state.
ii) If the new state is the goal state, quit and return this state.
iii) Otherwise add this state to the end of NODE-LIST
Advantages of BFS -
1) BFS will not get trapped exploring the blindally . This contrasts with depth first searching ,
which may follow a single , unfruitful path for a very long time , perhaps forever , before the path
aqctually terminates in a state that has no successor .
2) If there is a solution , then BFS is guarantees to find it . Further more, if there are multiple
solutions , then a minimal solution will be found . This is guaranteed by the fact that longer paths
are never explored and it all shorter ones have already been examined .
DFS is performed by going downward into a tree as quickly as possible. It does this by always
generating a child node from the most recently explored node, this generating that child's
children , and so on , until a goal is not found when a leaf node is reached or at the act off point
, the program backtracks to the most recently expended node and generates another of its
children . This process continues until a goal is found or failure occur .
A
/\
B C
/ /\
D E F
Output : A, B, C, D, E, F
1.If the initial state is a goal state , quit and return success.
2. Otherwise , loop until success or failure is signaled.
a) Generate a state , say E , and let it be the successor of the initial state. If there is no
successor , signal failure .
b) Call Depth-First Search with E as the initial state.
c) If the success is returned , signal success . Otherwise countinue in this loop.
Advantages of DFS -
1) It requires less memory because it stores the nodes on the current path only.
2) By chance , depth first search may find a solution without examining much of the search
space at all. This contrasts with BFS in which all parts of the tree must be examined to level n
before any nodes on level n+1 can be examined . This is particularly significant if many
acceptable solutions exist . Depth first search can stop when one of them is found .
1. BFS stands for Breadth First Search. DFS stands for Depth First Search.
BFS(Breadth First Search) uses Queue DFS(Depth First Search) uses Stack data
2. data structure for finding the shortest structure.
path.
3. BFS can be used to find single source In DFS, we might traverse through more
shortest path in an unweighted graph, edges to reach a destination vertex from a
because in BFS, we reach a vertex with source.
minimum number of edges from a
source vertex.
4. BFS is more suitable for searching DFS is more suitable when there are
verteces which are closer to the given solutions away from source.
source.
5. BFS considers all neighbors first and DFS is more suitable for game or puzzle
therefore not suitable for decision problems. We make a decision, then
making trees used in games or explore all paths through this decision.
puzzles. And if this decision leads to win situation,
we stop.
- Isha Jain
(0827It171035)