Notes
This function is in beta test. Please help improve it in the issues
here.
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 -11, which should be 0.
Please double check your code to solve this problem and try again.
Your Answer
Entering BinaryTree Entering BinaryTree val = 0 Entering BinaryTree val = 1 Entering BinaryTree val = 1 left.root = 0x5589f0e48220 right.root = 0 Entering ~BinaryTree Entering removeAll Entering removeAll root is nullptr Entering removeAll root is nullptr Entering ~BinaryTree Entering removeAll root is nullptr Entering BinaryTree Entering BinaryTree val = 2 Entering BinaryTree val = 3 Entering BinaryTree val = 3 left.root = 0x5589f0e48220 right.root = 0 Entering ~BinaryTree Entering removeAll Entering removeAll root is nullptr Entering removeAll root is nullptr Entering ~BinaryTree Entering removeAll root is nullptr Entering BinaryTree val = 2 Entering BinaryTree val = 2 left.root = 0x5589f0e48240 right.root = 0x5589f0e48260 Test 5: The sum of the tree is Entering sum Entering sumHelper Entering sumHelper Entering sumHelper Entering sumHelper Entering sumHelper Entering sumHelper Entering sumHelper Entering sumHelper Entering sumHelper Entering sumHelper Entering sumHelper Entering sumHelper Entering sumHelpe
JOJ Answer
Test 5: The sum of the tree is 8