///// STUDENT TO FILL OUT ALL THE STUB METHODS IN THIS CLASS. package tree234; /** * This is a modified version of an object-oriented implementation 2-3-4 trees given in class. * It does not have the method isEmpty and uses appropriate helper methods to insert Integer * objects in the tree. * @since 12/08/00 * @author Dung X. Nguyen, Copyright 2000 - All Rights Reserved. */ public class Tree234 { /** @SBGen Variable (,,,64) */ private ANode234 _rootNode; /** * Initializes this Tree234 to empty. */ public Tree234 () { //// STUDENT TO WRITE CODE. } /** * Inserts an Integer into this Tree234 without duplication. * @param n != null. * @throw IllegalArgumentException if n is null. */ public final void insert (Integer n) { //// STUDENT TO WRITE CODE. } /////////////////////////////////////// //Not visible outside of package Tree234(ANode234 root) { _rootNode = root; } Tree234 (Tree234 lTree, Integer n, Tree234 rTree) { _rootNode = new Node2 (lTree, n, rTree); } final void changeRoot (ANode234 newRoot) { _rootNode = newRoot; } final ANode234 root() { return _rootNode; } /** * Helps the parent tree insert data, using the other two siblings if necessary. * @param parent the parent of this Tree234. * @param sib1 one of the two sibblings of this Tree234. * @param sib2 the sibling of sib1 and this tree. * @param n an Integer to be properly inserted into parent. */ final void helpParentInsert (Tree234 parent, Tree234 sib1, Tree234 sib2, Integer n) { //// STUDENT TO WRITE CODE. } /** * Helps the parent tree insert data, using the one remaining sibling if necessary. * @param parent the parent of this tree. * @param sib one of the two sibblings of this Tree234. * @param n an Integer to be properly inserted into parent. */ final void helpParentInsert (Tree234 parent, Tree234 sib, Integer n) { //// STUDENT TO WRITE CODE. } /** * Helps the parent tree insert data with the knowledge that all the sibling trees are empty. * Called by an empty sibling tree. * @param parent the parent of this Tree234. * @param n an Integer to be properly inserted into parent. */ final void helpParentInsert (Tree234 parent, Integer n) { //// STUDENT TO WRITE CODE. } /** * Inserts data into this tree when its root node is a leaf. Called by one of the empty subtrees. * @param n an Integer to be properly inserted into this Tree234. */ final void insertAsLeaf (Integer n) { //// STUDENT TO WRITE CODE. } /** * Inserts data into this tree when its root node is NOT a leaf. Called by a non-empty subtree. * @param n an Integer to be properly inserted into this Tree234. */ final void insertNotAsLeaf (Integer n) { //// STUDENT TO WRITE CODE. } /** * This Tree234 is a subtree of a given parent tree. * Inserts n into this Tree234, splits, and re-attach to the parent tree if necessary * @param parent the parent of this Tree234. * @param n an Integer to be properly inserted into this Tree234. */ final void insertAsChild (Tree234 parent, Integer n) { //// STUDENT TO WRITE CODE. } /** * Attaches the 3 components of a 2-node to the root node in the proper order. * This Tree234 must be the parent of a non-empty Tree234. * @param lTree a 2-3-4 tree whose elements are less than n. * @param n a data element. * @param rTree a 2-3-4 tree whose elements are greater than n. */ final void attach (Tree234 lTree, Integer n, Tree234 rTree) { //// STUDENT TO WRITE CODE. } }