| 57 | |
| 58 | |
| 59 | int main() { |
| 60 | struct node *root = NULL; |
| 61 | int ch; |
| 62 | int x; |
| 63 | cout<<"Press 0 to exit else enter 1: "; |
| 64 | cin>>ch; |
| 65 | while(ch!=0) |
| 66 | { |
| 67 | cout<<"\n"<<"1.Insertion"<<"\n"<<"2.View"<<"\n"; |
| 68 | cout<<"\n"<<"Enter choice :"; |
| 69 | cin>>ch; |
| 70 | switch (ch) |
| 71 | { |
| 72 | case 1: |
| 73 | cout<<"Enter the value you want to insert in binary search tree: "; |
| 74 | cin>>x; |
| 75 | root = insert(root, x); |
| 76 | break; |
| 77 | case 2: |
| 78 | cout << "Inorder traversal: "; |
| 79 | inorder(root); |
| 80 | break; |
| 81 | |
| 82 | default: |
| 83 | printf("\nINVALID CHOICE !!"); |
| 84 | break; |
| 85 | } |
| 86 | } |
| 87 | return 0; |
| 88 | |
| 89 | |
| 90 | } |