Notes
This function is in beta test. Please help improve it in the issues
here.
================================================================= ==112317==ERROR: AddressSanitizer: heap-use-after-free on address 0x6030000001f8 at pc 0x559acdb06a62 bp 0x7ffd7d1e6c30 sp 0x7ffd7d1e6c20 READ of size 8 at 0x6030000001f8 thread T0 #0 0x559acdb06a61 in BinaryTree::removeAll(TreeNode*) /in/ex6.cpp:112 #1 0x559acdb06a78 in BinaryTree::removeAll(TreeNode*) /in/ex6.cpp:112 #2 0x559acdb0558e in BinaryTree::~BinaryTree() /in/ex6.cpp:25 #3 0x559acdb0618d in BinaryTree::depth() const /in/ex6.cpp:72 #4 0x559acdb09074 in test3() /in/compile/TestFunctions.cpp:110 #5 0x559acdb18b0c in std::_Function_handler<void (), void (*)()>::_M_invoke(std::_Any_data const&) /usr/include/c++/7/bits/std_function.h:316 #6 0x559acdb187e6 in std::function<void ()>::operator()() const /usr/include/c++/7/bits/std_function.h:706 #7 0x559acdb076b5 in runTests(int) /in/compile/TestFunctions.cpp:20 #8 0x559acdb04e70 in main /in/compile/test.cpp:13 #9 0x7fa117543c86 in __libc_start_main (/li
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
JOJ Answer
Test 3: The depth of the tree is 3