This repository has been archived by the owner on Oct 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbstmain.cpp
103 lines (102 loc) · 2.17 KB
/
bstmain.cpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include"display_tree1.h"
int main()
{
cout<<"\n\n\n BinarySearchTree \n\n\n";
int choice;
cout<<" 1. Integer BST \n";
cout<<" 2. Character BST \n";
cout<<" 3. Float BST \n";
cout<<" Enter Choice : ";
cin>>choice;
switch(choice)
{
case 1 :
{
cout<<"\n\n Creating The BST \n\n";
int data;
BST<int> b;
do
{
cout<<" Enter Data To Be Inserted : ";
cin>>data;
b.insert(data);
cout<<" Do You Have Any More Data (Type 0 Or 1) : ";
cin>>choice;
}while(choice);
display_bst(b.getRoot());
cout<<"\n\n\n";
do
{
cout<<" Enter Data To Be Deleted : ";
cin>>data;
b.deleteNode(data);
cout<<" Do You Have Any More Data To Be Deleted (Type 0 Or 1) : ";
cin>>choice;
}while(choice);
display_bst(b.getRoot());
cout<<"\n\n\n";
break;
}
case 2 :
{
cout<<"\n\n Creating The BST \n\n";
char data;
BST<char> b;
do
{
cout<<" Enter Data To Be Inserted : ";
cin>>data;
b.insert(data);
cout<<" Do You Have Any More Data (Type 0 Or 1) : ";
cin>>choice;
}while(choice);
b.display();
cout<<"\n\n\n";
do
{
cout<<" Enter Data To Be Deleted : ";
cin>>data;
b.deleteNode(data);
cout<<" Do You Have Any More Data To Be Deleted (Type 0 Or 1) : ";
cin>>choice;
}while(choice);
b.display();
cout<<"\n\n\n";
break;
}
case 3 :
{
cout<<"\n\n Creating The BST \n\n";
float data;
BST<float> b;
do
{
cout<<" Enter Data To Be Inserted : "
cin>>data;
b.insert(data);
cout<<" Do You Have Any More Data (Type 0 Or 1) : ";
cin>>choice;
}while(choice);
b.display();
cout<<"\n\n\n";
do
{
cout<<" Enter Data To Be Deleted : ";
cin>>data;
b.deleteNode(data);
cout<<" Do You Have Any More Data To Be Deleted (Type 0 Or 1) : ";
cin>>choice;
}while(choice);
b.display();
cout<<"\n\n\n";
break;
}
default :
{
cout<<"\n\n Default \n\n";
break;
}
}
cout<<"\n\n The End \n\n";
return 0;
}