Depth First Search

Tell us what’s happening:

Well, the phrase “What’s going on?” fully describe my understanding of subject.
Yes, I’ve seen the video at YouTube. I understand, what we should to go from node (which node? the node, for which we look for distance? or 0 node? distance from what?) by first path of this node and so far by next nodes, as possible, then we should go by second path from our start node as far as possible, etc. And find what? What should be a result? What we store during the process?
Who can explain?

I previously posted on this topic here, with explanations of both breadth-first and depth-first search: Breadth-Search Algorithm?

(Link, because I don’t care to try doing that ASCII art diagram again).

Yes, I saw this post, and I understand at this level of abstraction. I don’t understand on specific implementation level. How we define start node, how we mark nodes as “visited”, how we define end note? What result we need return from function? Is it may be some recursion?
I see algorithm as human. And I see a picture, full scheme. But my code will not see a picture

The start node will always be the root of the tree, and the end node will be the last node you visit – if it’s a Depth or Breadth First Search, then it’ll be the node you found, since you’re obviously not going to keep searching after you found things. As for marking nodes as “visited”, there’s no need to do so – the animation on Wikipedia is only marking them for illustrative purposes to show the algorithm in action.

If you do need to mark visited nodes for some reason , it’s going to entirely depend on how your tree is implemented – there’s no one right way to do it. Since trees have no cycles, most tree traversal algorithms have no need to mark nodes, unlike say Dijkstra’s algorithm on graphs.

For more on the subject of trees and traversal algorithms, I highly recommend the Khan Academy course on Algorithms which covers data structures like trees, and the algorithms that apply to them.

Thank you for help. I solved it. It turned out more easy, then I expected. Sometimes it’s need just simplify