1,944 views
1 votes
1 votes

Time complexity to compute the sum of k smallest element in the binary search tree??

can we do it like this-

Start doing the inorder traversal of the binary search tree, it will give the elements in increasing order. Start the counter k=0. As we get the elements we increment the counter and then stop the traversal when count reaches k and sum the elements which we have got. Its time complexity will be O(h+k).

Am i right??

plzz plzz explain someone

1 Answer

Related questions

4 votes
4 votes
4 answers
3
Parshu gate asked Nov 27, 2017
6,662 views
How many different binary search trees can be constructed using six distinct keys? 256 128 132 264