SHARE
TWEET

Untitled

a guest Sep 16th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public void inOrderSearch(TreeNode root){
  2.   if(root==null) return void;
  3.   Stack<TreeNode> stack = new Stack<>();
  4.   TreeNode p = root;
  5.   while(!stack.isEmpty() || p!=null){
  6.     if(p!=null){
  7.       stack.push(p);
  8.       p = p.left;
  9.     }else{
  10.       p = stack.top();
  11.       stack.pop();
  12.       System.out.println(p.value);
  13.       p=p.right;
  14.     }
  15.   }
  16. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top