Sunday, May 20, 2018

what do you mean by Preorder Traversal in tree?

Problem statement: what do you mean by Preorder traversal in tree?
  • Preorder traversal is defined as follows:
  1. visit the root
  2. traverse the left subtree in preorder
  3. traverse the right subtree in preorder 
  • Recursive Preorder Traversal:
  1. void  PreOrder(BinaryTreeNode root){
  2. if(root !=null){
  3. System.out.println(root.getData());
  4. PreOrder(root.getLeft());
  5. PreOrder(root.getRight());
  6. }
  7. }

No comments:

Post a Comment

How to run standalone mock server on local laptop

 Please download the standalone wiremock server from Direct download section at the bottom of the page.  Download and installation Feel fre...