Is there any way to find the kth largest of all possible full path sums in a binary search tree without using any other storage, like array? Initially I thought that if I go on finding the sum of paths from the right while increasing a pointer, with each new sum being the minimum as that and the previous sum (initially sum is infinite), breaking out when the count reaches k. However I just discovered that while the maximum leaf values be naturally sorted from right to left, the sums need not be so. So this method won't work. How can I do this?
0
votes