[algogeeks] Re: Sorting o(n) time

2007-03-19 Thread k3xji
Hi all, Quoted from Wikipedia: >Pigeonhole sorting, also known as count sort, is a sorting algorithm that >takes linear time (Θ(n)), which is the best possible performance for a sorting >algorithm since >one must inevitably look at each of the elements being sorted >at least once, regardless o

[algogeeks] Re: Sorting o(n) time

2007-03-18 Thread BiGYaN
Yeah, after finding the k-th element there is no need for further partitioning. This is logically true indeed. But in this case, I guess you have to do it for determining who'll get the Samosas and who the Gulabjamuns !!. --~--~-~--~~~---~--~~ You received this m

[algogeeks] Re: Sorting o(n) time

2007-03-17 Thread Amal
Do we have to partition after finding the kth element ? Will the Array not be partitioned when the base condition is met ? Amal. On 3/16/07, Rajiv Mathews <[EMAIL PROTECTED]> wrote: > > > On 3/16/07, Karthik Singaram L <[EMAIL PROTECTED]> wrote: > > > > How would the median algorithm get the top

[algogeeks] Re: Sorting o(n) time

2007-03-17 Thread BiGYaN
Yeah the average case is O(n) and worst case is O(n^2) as rightfully pointed out. But I still feel that this would be the best solution as the P(worst case) is quite less. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Gro

[algogeeks] Re: Sorting o(n) time

2007-03-16 Thread Arun
yes thats what i meant. its not just for median but can be used to find any nth order statistic(median is just a special case) On 3/16/07, Rajiv Mathews <[EMAIL PROTECTED]> wrote: > > > On 3/16/07, Karthik Singaram L <[EMAIL PROTECTED]> wrote: > > > > How would the median algorithm get the top k e

[algogeeks] Re: Sorting o(n) time

2007-03-16 Thread Rajiv Mathews
On 3/16/07, Karthik Singaram L <[EMAIL PROTECTED]> wrote: > > How would the median algorithm get the top k elements? > I think what he meant was, use the median by parting-in-5 algorithm to find the kth largest element. This can be done in O(n). Then just partition around this element to get the

[algogeeks] Re: Sorting o(n) time

2007-03-16 Thread Karthik Singaram L
How would the median algorithm get the top k elements? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this

[algogeeks] Re: Sorting o(n) time

2007-03-16 Thread Arun
cant we just use the linear median algorithm to select the top k elements? On 3/15/07, Karthik Singaram L <[EMAIL PROTECTED]> wrote: > > > Yes..but in the worst case you could partition the list into 1 and > n-1...we cannot say this deterministically. The average case is O(n) > but worst case woul

[algogeeks] Re: Sorting o(n) time

2007-03-15 Thread Karthik Singaram L
Yes..but in the worst case you could partition the list into 1 and n-1...we cannot say this deterministically. The average case is O(n) but worst case would still be O(n^2) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Gro

[algogeeks] Re: Sorting o(n) time

2007-03-15 Thread BiGYaN
You could try the quick-sort algo with these further modifications : every time you partition the list (assuming ascending) you leave out the entire working for the right hand part iff the size of the left hand part is >= m (m is the top m elements that you need). NB : Here left hand part indicate

[algogeeks] Re: Sorting o(n) time

2007-03-14 Thread Karthik Singaram L
radix sort would take O(nk) time in terms of the number of digits. And infact sorting is a much bigger problem than what we need. All that we need is the top k elements of an n element list. A strategy would be to use fibonacci heaps that have O(1) Decrease key. You can construct a heap out of t

[algogeeks] Re: Sorting o(n) time

2007-03-14 Thread chitta koushik
you can sort the students list according to marks in o(n) time by using RADIX SORT. On 3/14/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Dean of Computer Science department wants to keep the motivation > levels of students of data structure course high by giving incentives. > He has sugg