Write a program to create a tree for the following diagram.
LAB task #11
Submitted By:
Submission Date | |||||||
---|---|---|---|---|---|---|---|
1 | 2 | / | 1 | 2 | / | 1 | 8 |
Signature:______________ Max Marks:________ Marks Obtained:______
Task 1:
Write a program to create a Tree for the following diagram.
Insert Sequence of data: 52, 25, 60, 35, 20, 59, 65
2 Write a program to print the nodes of the following Tree diagram through Pre-Order,
In-Order and Post-Order
Syntax:
#include <iostream>
node *left, *right ;
};
node *newnode=new node;
node *nodeptr ;
if (root == NULL)
{
while (nodeptr !=NULL)
{
nodeptr=nodeptr->left;
}
}
}
nodeptr =nodeptr->right ;
}
}
}
}
}
{
return;
}
void inorder (struct node*nodeptr)
}
inorder (nodeptr -> left );
{
if(nodeptr==NULL)
}
int main()
{
cout<<"*******************************\n";
cout<<"3: postorder \n";
cout<<"4: inorder \n";
cin>>choice;
switch(choice)
break;
case 2:
inorder(root);
cout<< endl;
break;
default:
OUTPUT: