Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement