[algogeeks] Re: Give Algo to do this in O(n)

2011-10-10 Thread sravanreddy001
Without sorting the elements we have around n^2 elements to look from, to find the smalled element. But, after sort, we will have only n-1 elements to look from. So, O(nlogn) is what I see, the best case. Is there really a O(n) solution, as finding the diff between elements should be done

[algogeeks] Re: Give Algo to do this in O(n)

2011-10-10 Thread Dave
A radix sort would provide an O(n) solution for any fixed-size integer data type. Dave On Oct 10, 10:19 am, sravanreddy001 sravanreddy...@gmail.com wrote: Without sorting the elements we have around n^2 elements to look from, to find the smalled element. But, after sort, we will have only