Notes
This function is in beta test. Please help improve it in the issues
here.
================================================================= ==119508==ERROR: LeakSanitizer: detected memory leaks Direct leak of 24 byte(s) in 1 object(s) allocated from: #0 0x7eff8cc7e448 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0448) #1 0x56206a4905c9 in BinaryTree::copy(TreeNode*) /in/ex6.cpp:11 #2 0x56206a4907e3 in BinaryTree::copy(TreeNode*) /in/ex6.cpp:14 #3 0x56206a490fc9 in BinaryTree::BinaryTree(BinaryTree const&) /in/ex6.cpp:49 #4 0x56206a49e7a8 in test15() /in/compile/TestFunctions.cpp:233 #5 0x56206a4a8082 in std::_Function_handler<void (), void (*)()>::_M_invoke(std::_Any_data const&) /usr/include/c++/7/bits/std_function.h:316 #6 0x56206a4a7d5c in std::function<void ()>::operator()() const /usr/include/c++/7/bits/std_function.h:706 #7 0x56206a496c2b in runTests(int) /in/compile/TestFunctions.cpp:20 #8 0x56206a4904a0 in main /in/compile/test.cpp:13 #9 0x7eff8b50cc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.
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 15: Random Tree Deep Copy Check Copy Tree Sum before modification: 968 Original Tree Sum after modifying copy: 968
JOJ Answer
Test 15: Random Tree Deep Copy Check Copy Tree Sum before modification: 968 Original Tree Sum after modifying copy: 968