diff --git a/src/aud/exam/prep/tree/OrderedBinaryTreeNodeProcessor.java b/src/aud/exam/prep/tree/OrderedBinaryTreeNodeProcessor.java index b73ccc2..29ec384 100644 --- a/src/aud/exam/prep/tree/OrderedBinaryTreeNodeProcessor.java +++ b/src/aud/exam/prep/tree/OrderedBinaryTreeNodeProcessor.java @@ -1,6 +1,7 @@ package aud.exam.prep.tree; abstract class OrderedBinaryTreeNodeProcessor implements OrderedTreeProcessor> { + @Override public BinaryTreeNode newEmptyTree() { return null; @@ -9,28 +10,6 @@ abstract class OrderedBinaryTreeNodeProcessor implements OrderedTreeProcessor @Override public Iterable iterate(BinaryTreeNode tree) { return () -> - new BinaryTreeIterator<>(tree); - } - - @Override - public void print(BinaryTreeNode tree) { - printRec(tree, 0); - } - - private void printRec(BinaryTreeNode tree, int indent) { - if (tree == null) { - System.out.println("- *"); - return; - } - - System.out.println("-> " + tree.key); - - System.out.print(" |".repeat(indent)); - System.out.print(" L"); - printRec(tree.left, indent + 1); - - System.out.print(" |".repeat(indent)); - System.out.print(" L"); - printRec(tree.right, indent + 1); + new BinaryTreeIterator<>(tree); } } \ No newline at end of file diff --git a/src/aud/exam/prep/tree/RecursiveOrderedBinaryTreeNodeProcessor.java b/src/aud/exam/prep/tree/RecursiveOrderedBinaryTreeNodeProcessor.java index 876d56e..bb2a741 100644 --- a/src/aud/exam/prep/tree/RecursiveOrderedBinaryTreeNodeProcessor.java +++ b/src/aud/exam/prep/tree/RecursiveOrderedBinaryTreeNodeProcessor.java @@ -331,4 +331,26 @@ public class RecursiveOrderedBinaryTreeNodeProcessor extends OrderedBinaryTre return true; } + + @Override + public void print(BinaryTreeNode tree) { + printRec(tree, 0); + } + + private void printRec(BinaryTreeNode tree, int indent) { + if (tree == null) { + System.out.println("- *"); + return; + } + + System.out.println("-> " + tree.key); + + System.out.print(" |".repeat(indent)); + System.out.print(" L"); + printRec(tree.left, indent + 1); + + System.out.print(" |".repeat(indent)); + System.out.print(" L"); + printRec(tree.right, indent + 1); + } }