Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Pinterest
Share On Reddit
Share On Stumbleupon
Contact us
Hide Buttons

Depth First Search/Traversal in Binary Tree

Objec­tive: - Given a Binary Search Tree, Do the Depth First Search/Traversal .


  • Approach is quite sim­ple, use Stack.
  • First add the add to Stack.
  • Pop out an ele­ment from Stack and add its right and left chil­dren to stack.
  • Pop out an ele­ment and print it and add its children.
  • Repeat the above two steps until the Stack id empty.



Com­plete Code:


Depth-First-Search : 
 1 2 4 5 3 6 7

You may also like...