File tree Expand file tree Collapse file tree 1 file changed +31
-22
lines changed Expand file tree Collapse file tree 1 file changed +31
-22
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,9 @@ void BFT(node *n) {
98
98
}
99
99
}
100
100
101
+ /*
102
+ Prints the preorder traversal starting from the node n
103
+ */
101
104
void Pre (node *n) {
102
105
if (n != NULL ) {
103
106
std::cout << n->val << " " ;
@@ -106,6 +109,9 @@ void Pre(node *n) {
106
109
}
107
110
}
108
111
112
+ /*
113
+ Prints the inorder traversal starting from the node n
114
+ */
109
115
void In (node *n) {
110
116
if (n != NULL ) {
111
117
In (n->left );
@@ -114,6 +120,9 @@ void In(node *n) {
114
120
}
115
121
}
116
122
123
+ /*
124
+ Prints the postorder traversal starting from the node n
125
+ */
117
126
void Post (node *n) {
118
127
if (n != NULL ) {
119
128
Post (n->left );
@@ -145,28 +154,28 @@ int main() {
145
154
std::cin >> ch;
146
155
int x;
147
156
switch (ch) {
148
- case 1 :
149
- std::cout << " \n Enter the value to be Inserted : " ;
150
- std::cin >> x;
151
- Insert (root, x);
152
- break ;
153
- case 2 :
154
- std::cout << " \n Enter the value to be Deleted : " ;
155
- std::cin >> x;
156
- Remove (root, root, x);
157
- break ;
158
- case 3 :
159
- BFT (root);
160
- break ;
161
- case 4 :
162
- Pre (root);
163
- break ;
164
- case 5 :
165
- In (root);
166
- break ;
167
- case 6 :
168
- Post (root);
169
- break ;
157
+ case 1 :
158
+ std::cout << " \n Enter the value to be Inserted : " ;
159
+ std::cin >> x;
160
+ Insert (root, x);
161
+ break ;
162
+ case 2 :
163
+ std::cout << " \n Enter the value to be Deleted : " ;
164
+ std::cin >> x;
165
+ Remove (root, root, x);
166
+ break ;
167
+ case 3 :
168
+ BFT (root);
169
+ break ;
170
+ case 4 :
171
+ Pre (root);
172
+ break ;
173
+ case 5 :
174
+ In (root);
175
+ break ;
176
+ case 6 :
177
+ Post (root);
178
+ break ;
170
179
}
171
180
} while (ch != 0 );
172
181
You can’t perform that action at this time.
0 commit comments