-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
I used your code in VSCode with g++. The example you provide compiles and works fine. I amended your example in main to add 1000 nodes with keys in the range 1000 to 2000. The addition of the nodes appears to work but unfortunately there is a failure during the remove method and the code does not complete. Here is the updated main method
int main(){
AVL<int> avl;
avl.insert(9);
avl.insert(5);
avl.insert(10);
avl.insert(0);
avl.insert(6);
avl.insert(11);
avl.insert(-1);
avl.insert(1);
avl.insert(2);
cout << "Traversal of the AVL tree is " << endl;
avl.preOrder();
avl.levelOrder();
avl.remove(10);
int mycount = 1;
for (int mycount = 1; mycount <= 1000; mycount++)
{
avl.insert(1000 + mycount);
}
// The line below is printed
std::cout << "After Insertion of 1000 elements" << std::endl;
for (int mycount = 1; mycount <= 1000; mycount++)
{
avl.remove(1000 + mycount);
}
// The line below and subsequent lines do not get printed.
std::cout << "After Deletion of 1000 elements" << std::endl;
/* AVL Tree will be
9
/ \
1 10
/ \ \
0 5 11
/ / \
-1 2 6
*/
/* After Deletion of 10
1
/ \
0 9
/ / \
-1 5 11
/ \
2 6
*/
cout << "\nTraversal after deletion of 10" << endl;
avl.preOrder();
avl.levelOrder();
return 0;
}Metadata
Metadata
Assignees
Labels
No labels