Notes
This function is in beta test. Please help improve it in the issues
here.
================================================================= ==121961==ERROR: AddressSanitizer: heap-use-after-free on address 0x60300002a858 at pc 0x563c4435fa62 bp 0x7ffe42f875d0 sp 0x7ffe42f875c0 READ of size 8 at 0x60300002a858 thread T0 #0 0x563c4435fa61 in BinaryTree::removeAll(TreeNode*) /in/ex6.cpp:112 #1 0x563c4435fa78 in BinaryTree::removeAll(TreeNode*) /in/ex6.cpp:112 #2 0x563c4435e58e in BinaryTree::~BinaryTree() /in/ex6.cpp:25 #3 0x563c4435f18d in BinaryTree::depth() const /in/ex6.cpp:72 #4 0x563c4435f146 in BinaryTree::depth() const /in/ex6.cpp:73 #5 0x563c4435f146 in BinaryTree::depth() const /in/ex6.cpp:73 #6 0x563c4435f146 in BinaryTree::depth() const /in/ex6.cpp:73 #7 0x563c4435f146 in BinaryTree::depth() const /in/ex6.cpp:73 #8 0x563c4435f146 in BinaryTree::depth() const /in/ex6.cpp:73 #9 0x563c4435f146 in BinaryTree::depth() const /in/ex6.cpp:73 #10 0x563c4436a269 in test19() /in/compile/TestFunctions.cpp:276 #11 0x563c44371b0c in std::_
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 19: Very Large Balanced Tree
JOJ Answer
Test 19: Very Large Balanced Tree Depth: 9 Sum: 1013 In-order Traversal: 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 8 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 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