helper(left, right)
that takes the indices of the current subarray as arguments.left > right
, the subarray is empty, and we return None
.p = (left + right) // 2
.root
with the value nums[p]
.left
to p - 1
.p + 1
to right
.root.left
and root.right
respectively.root
node.helper(0, len(nums) - 1)
to initiate the recursion and construct the BST.