1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
int main()
{
root=insert(root,9);
insert(root,11);
insert(root,4);
insert(root,3);
insert(root,6);
insert(root,22);
insert(root,1);
insert(root,6);
insert(root,21);
insert(root,5);
insert(root,7);
insert(root,0);
insert(root,5);
insert(root,2);
string name="ROOT";
Experiment(root,name);
getch();
void Experiment (Tree * temp ,string x)
{
if(temp !=NULL)
{
cout<<"1 :"<<x<<":"<<temp->data<<endl;
Experiment (temp ->left,"left");
cout<<"2 :"<<x<<":"<<temp->data<<endl;
Experiment(temp->Right,"RIGHT");
cout<<"3 :"<<x<<":"<<temp->data<<endl;
}
}
}
|