Notes
This function is in beta test. Please help improve it in the issues
here.
================================================================= ==112327==ERROR: AddressSanitizer: heap-use-after-free on address 0x603000007bd8 at pc 0x5574a3b8ba62 bp 0x7ffef37546f0 sp 0x7ffef37546e0 READ of size 8 at 0x603000007bd8 thread T0 #0 0x5574a3b8ba61 in BinaryTree::removeAll(TreeNode*) /in/ex6.cpp:112 #1 0x5574a3b8bafe in BinaryTree::removeAll(TreeNode*) /in/ex6.cpp:113 #2 0x5574a3b8a58e in BinaryTree::~BinaryTree() /in/ex6.cpp:25 #3 0x5574a3b8b336 in BinaryTree::depth() const /in/ex6.cpp:77 #4 0x5574a3b8b146 in BinaryTree::depth() const /in/ex6.cpp:73 #5 0x5574a3b8b146 in BinaryTree::depth() const /in/ex6.cpp:73 #6 0x5574a3b8b146 in BinaryTree::depth() const /in/ex6.cpp:73 #7 0x5574a3b8b146 in BinaryTree::depth() const /in/ex6.cpp:73 #8 0x5574a3b8b146 in BinaryTree::depth() const /in/ex6.cpp:73 #9 0x5574a3b969e5 in test20() /in/compile/TestFunctions.cpp:287 #10 0x5574a3b9db0c in std::_Function_handler<void (), void (*)()>::_M_invoke(std::_Any_data con
Hints
Your answer may be identical to the JOJ answer in the first several lines.
However, the main problem you meet now is Runtime Error. And the exit code of your program is 1, which should be 0.
Please double check your code to solve this problem and try again.
Your Answer
Test 20: Very Large Random Tree
JOJ Answer
Test 20: Very Large Random Tree Depth: 12 Sum: 5561 In-order Traversal: 99 95 40 25 41 91 65 24 52 53 79 61 55 60 52 55 46 71 77 48 5 72 79 91 83 43 53 94 96 36 1 2 89 2 77 12 66 67 92 31 57 15 69 12 67 75 63 87 71 3 78 26 97 97 18 4 18 25 69 76 88 86 39 76 60 92 31 22 75 23 64 3 43 59 8 57 26 54 92 31 22 11 87 44 13 72 62 39 33 32 19 51 27 99 35 91 43 47 40 44 32 82 62 6 4 3 92 1 32