We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
morrisinorder.cpp
1 parent d74f4d3 commit 7828b8eCopy full SHA for 7828b8e
data_structures/morrisinorder.cpp
@@ -81,12 +81,21 @@ void morrisInorder(Btree *root) {
81
}
82
83
84
+void deleteAll(const Btree *const root) {
85
+ if (root) {
86
+ deleteAll(root->left);
87
+ deleteAll(root->right);
88
+ delete root;
89
+ }
90
+}
91
+
92
int main() {
93
// Testing morrisInorder funtion
94
Btree *root = NULL;
95
int i;
96
for (i = 1; i <= 7; i++) insert(&root, i);
97
cout << "Morris Inorder: ";
98
morrisInorder(root);
99
+ deleteAll(root);
100
return 0;
101
0 commit comments