Notes
This function is in beta test. Please help improve it in the issues
here.
================================================================= ==50314==ERROR: AddressSanitizer: heap-use-after-free on address 0x6030000000b0 at pc 0x564259c9828b bp 0x7fffb129d080 sp 0x7fffb129d070 READ of size 8 at 0x6030000000b0 thread T0 #0 0x564259c9828a in tree_depth_helper /in/ex6.cpp:101 #1 0x564259c9829a in tree_depth_helper /in/ex6.cpp:101 #2 0x564259c9829a in tree_depth_helper /in/ex6.cpp:101 #3 0x564259c98386 in BinaryTree::depth() const /in/ex6.cpp:106 #4 0x564259c9a45b in test3() /in/compile/TestFunctions.cpp:107 #5 0x564259ca9ca2 in std::_Function_handler<void (), void (*)()>::_M_invoke(std::_Any_data const&) /usr/include/c++/7/bits/std_function.h:316 #6 0x564259ca997c in std::function<void ()>::operator()() const /usr/include/c++/7/bits/std_function.h:706 #7 0x564259c98aa3 in runTests(int) /in/compile/TestFunctions.cpp:19 #8 0x564259c96f10 in main /in/compile/test.cpp:13 #9 0x7f6ec549dc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
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