Browse Source

Starting on inOrder traversal. Will find a way to use a stack for it

master
Raphael Roberts 6 years ago
parent
commit
19f2bf4874
  1. 14
      BST.java

14
BST.java

@ -61,8 +61,18 @@ public class BST {
// of the binary search tree.
public String inOrder() {
// TODO: implement this method using a non-recursive solution
return ""; // replace this statement with your own return
String return_string = "";
BSTNode[] stack = new BSTNode[size()];
int stack_pointer = 0;
BSTNode current = m_root;
while (true) {
while (current.getLeft() != null) {
stack[stack_pointer] = current;
stack_pointer++;
current = current.getLeft();
}
}
return return_string; // replace this statement with your own return
}
// This method returns the smallest element in the binary search tree. You

Loading…
Cancel
Save