Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have looked at a few Youtube tutorials on how a breath and depth first search work on a graph but I'm still a little confused.Does anyone have a very simple explanation of the searches possibly a useful video on them or any tips on how to understand it?
Thanks in advance.
Posted

The first place to start is Google, which lead me straight to Wiki:
http://en.wikipedia.org/wiki/Depth-first_search[^]
http://en.wikipedia.org/wiki/Breadth-first_search[^]

The depth first is easier than breadth first, but that is to be expected - it's a lot simpler an algorithm.
 
Share this answer
 
The way I try to look at Breadth First Search is that you try the immediate possibilities first. Depth First you stick to one path until you hit a dead end and then try a different path. Say you are in a room with two doors that's inside another room with two door and you need to find an exit.

Breadth First you would first open the two doors that are in the immediate room and then the two doors in the surrounding room.

Depth First you would open the immediate door and then open the surrounding door. If that fails you would open the second immediate door and then the second surrounding door.

link to an animation:
http://www.cs.sunysb.edu/~skiena/combinatorica/animations/search.html[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900