Question: Please implement a 2 - 3 - 4 Tree in Java using the following framework: public class TwoFourTree { private class TwoFourTreeItem { int values
Please implement a Tree in Java using the following framework:
public class TwoFourTree
private class TwoFourTreeItem
int values ;
int value; always exists.
int value; exists iff the node is a
node or node.
int value; exists iff the node is a
node.
boolean isLeaf true;
TwoFourTreeItem parent null; parent exists iff the node
is not root.
TwoFourTreeItem leftChild null; left and right child exist
iff the note is a nonleaf.
TwoFourTreeItem rightChild null;
TwoFourTreeItem centerChild null; center child exists iff the
node is a nonleaf node.
TwoFourTreeItem centerLeftChild null; centerleft and centerright
children exist iff the node is a nonleaf node.
TwoFourTreeItem centerRightChild null;
public boolean isTwoNode
return false;
public boolean isThreeNode
return false;
public boolean isFourNode
return false;
public boolean isRoot
return false;
public TwoFourTreeItemint value
public TwoFourTreeItemint value int value
public TwoFourTreeItemint value int value int value
private void printIndentsint indent
forint i ; i indent; i System.out.printf;
public void printInOrderint indent
ifisLeaf leftChild.printInOrderindent ;
printIndentsindent;
System.out.printfd
value;
ifisThreeNode
ifisLeaf centerChild.printInOrderindent ;
printIndentsindent;
System.out.printfd
value;
else ifisFourNode
ifisLeaf centerLeftChild.printInOrderindent ;
printIndentsindent;
System.out.printfd
value;
ifisLeaf centerRightChild.printInOrderindent ;
printIndentsindent;
System.out.printfd
value;
ifisLeaf rightChild.printInOrderindent ;
TwoFourTreeItem root null;
public boolean addValueint value
return false;
public boolean hasValueint value
return false;
public boolean deleteValueint value
return false;
public void printInOrder
ifroot null root.printInOrder;
public TwoFourTree
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
