Reading notes for Code Fellows!
Recursion is the most common method of tree traversal and utilizes a call stack. There are three methods for depth first traversal. They are:
root -> left -> rightcurrent nodecurrent valueleft child of the current nodecurrent to stack then make child the current node and go back to 2right child of the current nodecurrent to stack then make child the current node and go back to 2current node, pop the node off of the stack and go back to 2Output from example tree:
A -> B -> D -> E -> C -> Fleft -> root -> rightcurrent nodeleft child of the current nodecurrent to stack and make child the current node and go back to 2current valueright child of the current nodecurrent to stack and make child the current node and go back to 2current node, pop the node off of the stack and go back to 2Output from example tree:
D -> B -> E -> A -> F -> Cleft -> right -> rootcurrent nodeleft child of the current nodecurrent to stack then make child the current node and go back to 2right child of the current nodecurrent to stack then make child the current node and go back to 2current valuecurrent node, pop the node off of the stack and go back to 2Output from example tree:
D -> E -> B -> F -> C -> A