Question: Please use the 2 3 4 tree.h ! ! ! Problem: 2 - 3 - 4 trees are generalization of the previously discussed
Please use the tree.h Problem: trees are generalization of the previously discussed trees, and a spacial case of B or multiway trees.There are three cases for the splitting of a node.Identify, by line numbers from the code in tree.h the cases.Of these cases, one case had sub cases and another had there cases. Identify the sub cases by line number. Write a driver using tree.h which displays by level the tree ie our usual handdrawn graphical representation after EACH of the adds :
the driver is also to display the tree, in this pseudographical form. This is tree.h: template class TwoThreeFourNode
public:BaseData firstInfo, secondInfo thirdInfo;
TwoThreeFourNode firstChildsecondChildthirdChildfourthChild;
TwoThreeFourNode;;
template
TwoThreeFourNode::TwoThreeFourNode
firstChildNULL; secondChildNULL;thirdChildNULL;fourthChildNULL;
firstInfoBaseData NULL;secondInfoBaseData NULL;thirdInfoBaseData NULL;
template
class TwoThreeFourTree
protected:
TwoThreeFourNode root; int compareconst BaseData& x const BaseData& y;
private:
void splitRoot TwoThreeFourNode & t;
void splitChildOfTwoThreeFourNode & tree,TwoThreeFourNode & parent;
void splitChildOf
TwoThreeFourNode & tree,TwoThreeFourNode & parent;
int nodeType TwoThreeFourNode t;
void insertData TwoThreeFourNode tBaseData newData;
bool leafNode TwoThreeFourNode t;
int whichChild TwoThreeFourNode t BaseData data;
bool privSearchTwoThreeFourNode rt BaseData target,BaseData& item;
void inord TwoThreeFourNode rt void processNodeBaseData& item;
void preord TwoThreeFourNode rt void processNodeBaseData& item;
void postord TwoThreeFourNode rt void processNodeBaseData& item;
void delauxTwoThreeFourNode &rt;
void copyAuxTwoThreeFourNode src TwoThreeFourNode dest;
public: TwoThreeFourTree int precedesconst BaseData& x const BaseData& y;
TwoThreeFourTreeconst TwoThreeFourTree & initTwoThreeFourTree;
void operator const TwoThreeFourTree & initTwoThreeFourTree;
~TwoThreeFourTree; bool add BaseData item;
bool searchBaseData target, BaseData& item;
void inOrderTravvoid processNodeBaseData& item;
void preOrderTravvoid processNodeBaseData& item;
void postOrderTravvoid processNodeBaseData& item;;
template
TwoThreeFourTree::TwoThreeFourTreeintprecedesconst BaseData& x const BaseData& y
root NULL;compare precedes;
template
void TwoThreeFourTree::copyAuxTwoThreeFourNode src TwoThreeFourNode dest
if src NULL
destfirstInfosrcfirstInfo;destsecondInfosrcsecondInfo; destthirdInfosrcthirdInfo;
if srcfirstChild NULL
TwoThreeFourNode temp;tempnew TwoThreeFourNode;
destfirstChildtemp;copyAuxsrcfirstChild,temp;
if srcsecondChild NULL
TwoThreeFourNode temp;tempnew TwoThreeFourNode;
destsecondChildtemp;copyAuxsrcsecondChildtemp;
if srcthirdChild NULL
TwoThreeFourNode temp;tempnew TwoThreeFourNode;
destthirdChildtemp;copyAuxsrcthirdChild,temp;
if srcfourthChild NULL
TwoThreeFourNode temp;tempnew TwoThreeFourNode;
destfourthChildtemp;copyAuxsrcfourthChild,temp;
template
TwoThreeFourTree::TwoThreeFourTreeconst TwoThreeFourTree & initTwoThreeFourTree
compareinitTwoThreeFourTree.compare;
if initTwoThreeFourTreeroot NULL rootNULL;
else rootnew TwoThreeFourNode;
copyAuxinitTwoThreeFourTreeroot,root;
template
void TwoThreeFourTree::operator const TwoThreeFourTree & initTwoThreeFourTree
if root NULL
delauxroot;
compareinitTwoThreeFourTree.compare;
if initTwoThreeFourTreeroot NULL rootNULL;
else rootnew TwoThreeFourNode;
copyAuxinitTwoThreeFourTreeroot,root;
template
bool TwoThreeFourTree::addBaseData item
bool done;TwoThreeFourNode pprev; int w;
if root NULL
root new TwoThreeFourNode ; rootfirstInfo item;
returntrue;
if nodeTyperoot splitRootroot;
p root;prev NULL; done false;
while done
if nodeTypep if nodeTypeprev
splitChildOfp prev; else splitChildOfp prev;
w whichChildp item;
SORRY rest of the code picture format because of cheeg limit more then character Thank You
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
