Question: Please use the 2 3 4 tree.h ! ! ! Problem: 2 - 3 - 4 trees are generalization of the previously discussed

Please use the "234tree.h "!!! Problem: 2-3-4 trees are generalization of the previously discussed 2-3 trees, and a spacial case of B or multi-way trees.There are three cases for the splitting of a 234 node.Identify, by line numbers from the code in 234_tree.h, the 3 cases.Of these 3 cases, one case had 2 sub cases , and another had there cases. Identify the sub cases by line number. Write a driver (using 234_tree.h) which displays by level the tree (i.e. our usual hand-drawn graphical representation) after EACH of the adds :
60,50,70,40,80,30,90,20,100,10,66,44,33. the driver is also to display the tree, in this pseudo-graphical form. This is "234tree.h": template class TwoThreeFourNode
{ public:BaseData firstInfo, secondInfo, thirdInfo;
TwoThreeFourNode *firstChild,*secondChild,*thirdChild,*fourthChild;
TwoThreeFourNode();};
template
TwoThreeFourNode::TwoThreeFourNode()
{firstChild=NULL; secondChild=NULL;thirdChild=NULL;fourthChild=NULL;
firstInfo=(BaseData) NULL;secondInfo=(BaseData) NULL;thirdInfo=(BaseData) NULL;}
template
class TwoThreeFourTree
{ protected:
TwoThreeFourNode *root; int (*compare)(const BaseData& x, const BaseData& y);
private:
void splitRoot (TwoThreeFourNode *& t);
void splitChildOf2(TwoThreeFourNode *& tree,TwoThreeFourNode *& parent);
void splitChildOf3
(TwoThreeFourNode *& tree,TwoThreeFourNode *& parent);
int nodeType (TwoThreeFourNode * t);
void insertData (TwoThreeFourNode * t,BaseData newData);
bool leafNode (TwoThreeFourNode * t);
int whichChild (TwoThreeFourNode * t, BaseData data);
bool privSearch(TwoThreeFourNode * rt, BaseData target,BaseData& item);
void inord (TwoThreeFourNode *rt, void (*processNode)(BaseData& item));
void preord (TwoThreeFourNode *rt, void (*processNode)(BaseData& item));
void postord (TwoThreeFourNode *rt, void (*processNode)(BaseData& item));
void delaux(TwoThreeFourNode *&rt);
void copyAux(TwoThreeFourNode * src, TwoThreeFourNode * dest);
public: TwoThreeFourTree (int (*precedes)(const BaseData& x, const BaseData& y));
TwoThreeFourTree(const TwoThreeFourTree & initTwoThreeFourTree);
void operator =(const TwoThreeFourTree & initTwoThreeFourTree);
~TwoThreeFourTree(); bool add (BaseData item);
bool search(BaseData target, BaseData& item);
void inOrderTrav(void (*processNode)(BaseData& item));
void preOrderTrav(void (*processNode)(BaseData& item));
void postOrderTrav(void (*processNode)(BaseData& item));};
template
TwoThreeFourTree::TwoThreeFourTree(int(*precedes)(const BaseData& x, const BaseData& y))
{ root = NULL;compare = precedes;}
template
void TwoThreeFourTree::copyAux(TwoThreeFourNode *src, TwoThreeFourNode *dest)
{ if (src !=NULL)
{dest->firstInfo=src->firstInfo;dest->secondInfo=src->secondInfo; dest->thirdInfo=src->thirdInfo;
if (src->firstChild != NULL)
{ TwoThreeFourNode *temp;temp=new TwoThreeFourNode;
dest->firstChild=temp;copyAux(src->firstChild,temp);}
if (src->secondChild != NULL)
{TwoThreeFourNode *temp;temp=new TwoThreeFourNode;
dest->secondChild=temp;copyAux(src->secondChild,temp); }
if (src->thirdChild != NULL)
{ TwoThreeFourNode *temp;temp=new TwoThreeFourNode;
dest->thirdChild=temp;copyAux(src->thirdChild,temp); }
if (src->fourthChild != NULL)
{ TwoThreeFourNode *temp;temp=new TwoThreeFourNode;
dest->fourthChild=temp;copyAux(src->fourthChild,temp);}}}
template
TwoThreeFourTree::TwoThreeFourTree(const TwoThreeFourTree & initTwoThreeFourTree)
{ compare=initTwoThreeFourTree.compare;
if (initTwoThreeFourTree.root == NULL) root=NULL;
else { root=new TwoThreeFourNode;
copyAux(initTwoThreeFourTree.root,root);}}
template
void TwoThreeFourTree::operator =(const TwoThreeFourTree & initTwoThreeFourTree)
{ if (root != NULL)
{delaux(root);}
compare=initTwoThreeFourTree.compare;
if (initTwoThreeFourTree.root == NULL) root=NULL;
else { root=new TwoThreeFourNode;
copyAux(initTwoThreeFourTree.root,root);}}
template
bool TwoThreeFourTree::add(BaseData item)
{ bool done;TwoThreeFourNode *p,*prev; int w;
if (root == NULL)
{ root = new TwoThreeFourNode ; root->firstInfo = item;
return(true);}
if (nodeType(root)==4) splitRoot(root);
p = root;prev = NULL; done = false;
while (!done)
{ if (nodeType(p)==4) if (nodeType(prev)==2)
splitChildOf2(p, prev); else splitChildOf3(p, prev);
w = whichChild(p, item);
SORRY rest of the code picture format because of cheeg limit more then 5000 character !!!! Thank You !!!
 Please use the "234tree.h "!!! Problem: 2-3-4 trees are generalization of

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!