Tree student program
Tree student program
Struct Node{
Int id;
String Name;
Int marks;
Node *Left;
Node *Right;
};
Class student{
Public:
Node *Root;
Student(){
Root=NULL;
If(temp==NULL){
Temp=new Node;
Temp->id=d;
Cin>>temp->Name;
Cin>>temp->marks;
Temp->Left=NULL;
Temp->Right=NULL;
If(Root==NULL){
Root=temp;
}
}
Else if(temp->id>d){
Temp->Left=Insert(d,temp->Left);
Else{
Temp->Right=Insert(d,temp->Right);
Return temp;
Int f=0;
If(temp!=NULL){
Cout<<”Student id is “<<temp->id<<endl;
Predisplay(temp->Left);
Predisplay(temp->Right);
F=1;
/*if(f==0){
}*/
If(temp!=NULL){
If(temp->id==d){
Cout<<”Student id is “<<temp->id<<endl;
Cout<<”Student Name is “<<temp->Name<<endl;
Else if(temp->id>d){
Search(d,temp->Left);
Else{
Search(d,temp->Right);
Else {
};
Int main() {
Student s1;
Int ch;
While(true){
Cout<<””<<endl;
Cout<<”Menu”<<endl;
Cout<<”4. Exit”<<endl;
Cin>>ch;
Switch(ch){
Case 1:
Int ss;
Cin>>ss;
S1.Insert(ss,s1.Root);
Break;
Case 2:
S1.predisplay(s1.Root);
Break;
Case 3:
Int sea;
Cin>>sea;
S1.Search(sea,s1.Root);
Break;
Case 4:
Return 0;
Break;
Default:
Cout<<”Invalid input…..”<<endl;
Return 0;
}