Click here to Skip to main content
15,946,342 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.

The first place to start is Google, which lead me straight to Wiki:[^][^]

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:[^]
Share this answer

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