Skip to content

Commit a63bc67

Browse files
committed
binary tree preorder iterator
1 parent 382184b commit a63bc67

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

PuzzleCoding/src/BTreeIterator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,12 @@ public Node preOrderNext() {
7474

7575
public Node postOrderNext() {
7676
if (hasNext()) {
77-
if (stack.peek().right == null || leftVisitedStack.contains(stack.peek().right)) {
77+
if (stack.peek().right == null ||
78+
leftVisitedStack.contains(stack.peek().right)) {
79+
7880
Node node = stack.pop();
7981
return node;
82+
8083
} else {
8184
leftVisitedStack.push(stack.peek().right);
8285
pushLeft(stack.peek().right);

0 commit comments

Comments
 (0)