15,947,958 members
1.00/5 (1 vote)
See more:
Introduction to Graph with Breadth First Search(BFS) and Depth First Search(DFS) Traversal Implemented in C++

DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously. - OriginalGriff[/edit]
Posted
Updated 24-Jun-11 3:21am
v2

Solution 1

If you are going to post your homework, at least try to make it look like you have attempted to do something yourself!

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, or learn the Magic Words: "Do you want fries with that?"

Sergey Alexandrovich Kryukov 24-Jun-11 23:50pm
A 5 for telling all that, but... come on, what fries?
Did you notice the notion also makes no sense? Please see my answer.
--SA
OriginalGriff 25-Jun-11 3:47am
This is Q&A! Half the questions make no sense... :laugh:
Sergey Alexandrovich Kryukov 25-Jun-11 17:25pm
Half? You're such an optimist! :-)
--SA

Solution 2

If you think a bit you would clearly see that those algorithms are inapplicable for a general graph by at least one simple reason: for such a graph there is no way to tell the width from breadth. :-) The algorithms are only applicable to the special case of graph called "tree" when the root node is given. Tree is defined as a graph without cycle. Unlike many graph problems, this search is absolutely trivial, but it could not do anything without at least reading of the basic definitions.

—SA

Espen Harlinn 25-Jun-11 11:19am
A5 ;-)
Sergey Alexandrovich Kryukov 25-Jun-11 17:24pm
Thank you, Espen.
--SA