Notes
This function is in beta test. Please help improve it in the issues
here.
================================================================= ==53346==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new vs operator delete []) on 0x603000000040 #0 0x7f2d9900c480 in operator delete[](void*) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe1480) #1 0x56332e1ac051 in BinaryTree::~BinaryTree() /in/ex6.cpp:87 #2 0x56332e1ac933 in buildBalancedTree(int) /in/compile/TestFunctions.cpp:37 #3 0x56332e1ac8b1 in buildBalancedTree(int) /in/compile/TestFunctions.cpp:36 #4 0x56332e1ac8b1 in buildBalancedTree(int) /in/compile/TestFunctions.cpp:36 #5 0x56332e1ac8b1 in buildBalancedTree(int) /in/compile/TestFunctions.cpp:36 #6 0x56332e1ac8b1 in buildBalancedTree(int) /in/compile/TestFunctions.cpp:36 #7 0x56332e1ac8b1 in buildBalancedTree(int) /in/compile/TestFunctions.cpp:36 #8 0x56332e1ac8b1 in buildBalancedTree(int) /in/compile/TestFunctions.cpp:36 #9 0x56332e1ac8b1 in buildBalancedTree(int) /in/compile/TestFunctions.cpp:36 #10 0x56332e1b5f90 in test19(
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 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 1 3 1 2 1 4 1 2 1 3 1 2 1 6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