00:01
Hello students, here is the problem by the recursive traversing the binary search and calculating the sum of the values in the left and the right branches.
00:10
So where here is the provided python function with the compare branches, compare branches calculate whether the left or the right branch of the binary tree represents an array has the largest sum of the node value.
00:24
So where the function defines an inner recursive function called as the calculate sum.
00:33
So where that takes an index as the parameter.
00:36
So this inner function is used to calculate the sum of the node values starting from the given index.
00:43
So inside this calculate sum, it checks if the current index is within the bonds of the tree array.
00:50
If the node is not placeholder, that is the if it is in a minus one, then if the conditions are met, then it calculates the sum recursively.
01:00
So it calculates the sum of the left subtree with the 2 into index plus 1 and the sum of the right subtree 2 into index plus 2.
01:13
So it returns the sum of the current nodes value and the sum of the left and the right subtree...