@ Rishabh,

we have to find the sum of k smallest numbers. so we will stop when our count will reach k. If u want to find the sum of n elements that is all the elements then just simply do any traversal and find the sum in O(n) time.

we have to find the sum of k smallest numbers. so we will stop when our count will reach k. If u want to find the sum of n elements that is all the elements then just simply do any traversal and find the sum in O(n) time.