From 19f2bf4874ae9688f967562bfe7e61a94c9f7f02 Mon Sep 17 00:00:00 2001 From: Raphael Roberts Date: Mon, 11 Nov 2019 10:18:49 -0600 Subject: [PATCH] Starting on inOrder traversal. Will find a way to use a stack for it --- BST.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/BST.java b/BST.java index 0660dcd..3aa2dc8 100644 --- a/BST.java +++ b/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