Question: Implement the inorder tree walk() function Implement the search() function Implement the iterative search() Implement the minimum() function Implement the maximum() function Implement the successor()

Implement the inorder tree walk() function

Implement the search() function

Implement the iterative search()

Implement the minimum() function

Implement the maximum() function

Implement the successor() function

Implement the insert() function

***post screenshots of code too please****

package ds;

public class BinarySearchTree {

public TreeNode root;

public BinarySearchTree () {

root = null;

}

public void inorder_tree_walk (TreeNode x) {

}

public TreeNode search (TreeNode x, int k) {

}

public TreeNode iterative_search (int k) {

}

public TreeNode minimum () {

}

public TreeNode maximum () {

}

public TreeNode successor (TreeNode x) {

}

public void insert (int k) {

}

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

int[] array = {15, 6, 18, 3, 7, 17, 20, 2, 4, 13, 9};

BinarySearchTree bst;

TreeNode n;

bst = new BinarySearchTree();

for (int i = 0; i < array.length; i++)

bst.insert(array[i]);

System.out.println("Inorder_tree_walk starts ------------

------");

bst.inorder_tree_walk(bst.root);

System.out.println("Inorder_tree_walk ends --------------

----");

System.out.print(" ");

System.out.println("Search starts ------------------");

n = bst.search(bst.root, 13);

System.out.println("found: " + n.key);

System.out.println("Search ends ------------------");

System.out.print(" ");

System.out.println("Iterative search starts -------------

-----");

n = bst.iterative_search(4);

System.out.println("found: " + n.key);

System.out.println("Iterative search ends ---------------

---");

System.out.print(" ");

System.out.println("Minimum starts ------------------");

n = bst.minimum();

System.out.println("Minimum key is " + n.key);

System.out.println("Minimum ends ------------------");

System.out.print(" ");

System.out.println("Maximum starts ------------------");

n = bst.maximum();

System.out.println("Maximum key is " + n.key);

System.out.println("Maximum ends ------------------");

System.out.print(" ");

System.out.println("Successor starts ------------------

");

n = bst.successor(bst.root.left.right.right);

System.out.println("Successor key is " + n.key);

System.out.println("Successor ends ------------------");

System.out.print(" ");

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!