dfs bfs and ucs in r
TRANSCRIPT
DFS vs BFS
Depth First Search (DFS) Breadth First Search (BFS)&Uniform Cost Search (UCS) Vichhaiy SEREY (ID: 5938445)
Professors:Ananta Srisuphab Piyanuch Silapachote 9/28/2016ITCS6611
1
OutlineWhat they areDFS and BFSTake a look at a scenarioTest Scenario 1Test Scenario 2Let talk about UCSConclusion9/28/2016ITCS6612
What they areThey both are search algorithms which can be used to search path to a vertex (node) in the tree or unweighted graph domain.
9/28/2016ITCS6613DFS:Implement with Stack (LIFO)It attempts to search as far as possible to find the goal nodeIt cares to reach the goal, but it doesnt care if the path is shorterIf the goal is deep, it is good
BFS:Implement with Queue (FIFO)Search layer by layer, as close as possibleIf the goal is not far, the BFS is goodIf you care the shorter path to the goal, it is goodBut yes, it consumes more time and memory as the goal is deeperTheyre good for their scenarios
Consider this tree:9/28/2016ITCS6614ABCDEIFHJKMLN
Take a look in one scenarioSuppose a company has many branches (routers) and all branches are formed topology as showing below.We want to know which path host A sends data to host B9/28/2016ITCS6615
DFS & BFS
DFSBFS#7#5
9/28/2016ITCS6616
DFSBFS9/28/2016ITCS6617
7
Try from A to SR
9/28/2016ITCS6618
same
About Uniform Cost Search (UCS)It is one of the best search algorithm compare to DFS or BFS because it determines the best path through the actual path cost NOT just count number of nodes.
implement with priority queue9/28/2016ITCS6619
Uniform Cost Search Algorithm
9/28/2016ITCS66110
Test old scenario: routers
9/28/2016ITCS66111
ConclusionDFS uses Stack and BFS uses QueueDFS tries as deep as possible & BFS tries layer by layerDFS is simpler compared to BFSWe cannot say which one is better. It depends on which scenario we want to apply.If the goal is deep, DFS would be betterIf the goal is not far, BFS would be better
9/28/2016ITCS66112