Question: Please finish everything marked TODO. BST.java import java.util.ArrayList; import java.util.Collection; import java.util.List; public class BST implements Tree { private int height; private int size; private

Please finish everything marked TODO.

BST.java

import java.util.ArrayList; import java.util.Collection; import java.util.List;

public class BST> implements Tree {

private int height; private int size; private BinaryNode root;

public BST(){ this.root = null; this.height = 0; this.size = 0; }

// TODO: BST public BST(BinaryNode root){ }

// Access field public BinaryNode root() { return this.root; }

// Basic properties public int height() { return this.height; } public int size() { return this.size; } public boolean isBalanced() { return root.isBalanced(); }

// TODO: updateHeight - Update the root height to reflect any changes public void updateHeight() { }

// Traversals that return lists // TODO: Preorder traversal public List preOrderList() { return new ArrayList<>(); }

// TODO: Inorder traversal public List inOrderList() { return new ArrayList<>(); }

// TODO: Postorder traversal public List postOrderList() { return new ArrayList<>(); }

// Helpers for BST/AVL methods // TODO: extractRightMost // This will be called on the left subtree and will get the maximum value. public BinaryNode extractRightMost(BinaryNode curNode) { return null; }

// AVL & BST Search & insert same // TODO: search public BinaryNode search(E elem) { return null; }

// TODO: insert public void insert(E elem) {

}

// TODO: delete public BinaryNode delete(E elem) { return null; }

// Stuff to help you debug if you want // Can ignore or use to see if it works. static > Tree mkBST (Collection elems) { Tree result = new BST<>(); for (E e : elems) result.insert(e); return result; } public TreePrinter.PrintableNode getLeft() { return this.root.hasLeft() ? this.root.left() : null; } public TreePrinter.PrintableNode getRight() { return this.root.hasRight() ? this.root.right() : null; } public String getText() { return (this.root != null) ? this.root.getText() : ""; } }

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!