using namespace std;
class Two3;
class Two3Node{
friend class Two3;
private:
int data1, data2;
Two3Node *lc, *mc, *rc, *par; //leftchild, rightchild, middlechild and parentchild
public:
Two3Node();
~Two3Node();
};
class Two3{
private:
Two3Node *root;
public:
Two3();
~Two3();
bool Insert(int x);
bool Search(int x);
Two3Node *SearchNode(int x);
bool IsEmpty();
bool Is2Node(Two3Node *check);
bool Is3Node(Two3Node *check);
void Split(Two3Node *&n, int num);
int Min(int n1, int n2, int n3);
int Mid(int n1, int n2, int n3);
int Max(int n1, int n2, int n3);
};
bool Two3::Search(int x){
Two3Node *temp= root;
while(temp!=NULL){
if(temp->data1==x || temp->data2==x)
return true;
else if(temp->data1!=-1 && temp->data2!=-1){
if(x<temp->data1)
temp=temp->lc;
else if(x<temp->data2)
temp=temp->mc;
else
temp=temp->rc;
}
else if(temp->data1!=0 && temp->data2==-1){
if(x<temp->data1)
temp=temp->lc;
else
temp=temp->mc;
}
} //end while
return false;
}
어케되는지도 모르겠음
인댄트 좀 쳐넣어라