Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void inOrderSearch(TreeNode root){
- if(root==null) return void;
- Stack<TreeNode> stack = new Stack<>();
- TreeNode p = root;
- while(!stack.isEmpty() || p!=null){
- if(p!=null){
- stack.push(p);
- p = p.left;
- }else{
- p = stack.top();
- stack.pop();
- System.out.println(p.value);
- p=p.right;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement