# DFS algorithm and how do I show/put it into practice? [closed]

I'm new to DFS algorithm and I'm trying to figure it out.

The main concepts I get from it is that you have a stack of nodes, and they have a value, and can contain children-nodes (Even called branches or leaves) that can contains nodes with values.

So let's say that I have a Tree containing 15 nodes like this. I would understand that the algorithm goes A-N-O-B-D-J-L-M-K-C-E-F-H-G-I, If you were to go in alphabetic order.

My confusion is this how to put this algorithm into practice (such as coding it). How should I see this tree like (Array, List?)

And if some of the children are connected to each other can it still be a DFS algorithm? • I don't understand what you're asking. DFS is a well-defined algorithm that works perfectly well when the graph isn't a tree. And, although implementation questions are off-topic, here, you'd implement the tree/graph using any appropriate data structure. – David Richerby Feb 11 '17 at 10:38
• @DavidRicherby Yes I can understand now to why my question is confusing. In this case I was asking in how I should think regarding implementing DFS to code. How should I implement the tree structure in the best-case scenario. – Bojje Feb 11 '17 at 19:16