Re: [CentOS] [OT] stable algorithm with complexity O(n)

2008-12-17 Thread NiftyClusters T Mitchell
On Sat, Dec 13, 2008 at 10:24 AM, David Hláčik wrote: > Hi guys, > > i am really sorry for making offtopic, hope you will not kill me, but > this is for me life important problem which needs to be solved within > next 12 hours.. > > I have to create stable algorithm for sorting n numbers from inte

Re: [CentOS] [OT] stable algorithm with complexity O(n)

2008-12-14 Thread David Hláčik
Thank you guys for help and support! My homework is done and waiting for grading. Here it comes - bucket sort with time complexity O(n) == linear complexity #! /usr/bin/python def sort(numbers): "sort n positive integers in O(n) provided that they are all from interval [1, n^2]"

Re: [CentOS] [OT] stable algorithm with complexity O(n)

2008-12-14 Thread Nicolas Thierry-Mieg
Jerry Franz wrote: > > Nicolas Thierry-Mieg wrote: >> Jerry Franz wrote: >>> Marko Vojinovic wrote: >>> [...] Basically, count the number of appearances of every number in your set. If you have a set a priori bounded from above and below --- which you do, [1, n^2] --- you f

Re: [CentOS] [OT] stable algorithm with complexity O(n)

2008-12-14 Thread Jerry Franz
Marko Vojinovic wrote: > On Sunday 14 December 2008 03:33, Jerry Franz wrote: >> [...] >> By definition, your proposed algorithm is O(n^2), not O(n). >> >> ;) > > Oh, you mean because the upper bound is n^2, right? Sure, of course, this > particular case is O(n^2). Your proposal in your other p

Re: [CentOS] [OT] stable algorithm with complexity O(n)

2008-12-14 Thread Jerry Franz
Nicolas Thierry-Mieg wrote: > > Jerry Franz wrote: >> Marko Vojinovic wrote: >> [...] >>> Basically, count the number of appearances of every number in your set. If >>> you >>> have a set a priori bounded from above and below --- which you do, >>> [1, n^2] --- you first allocate an array of in

Re: [CentOS] [OT] stable algorithm with complexity O(n)

2008-12-14 Thread Nicolas Thierry-Mieg
Jerry Franz wrote: > > Marko Vojinovic wrote: > [...] >> Basically, count the number of appearances of every number in your set. If >> you >> have a set a priori bounded from above and below --- which you do, >> [1, n^2] --- you first allocate an array of integers of length n^2. > > By defin

Re: [CentOS] [OT] stable algorithm with complexity O(n)

2008-12-14 Thread Marko Vojinovic
On Sunday 14 December 2008 03:33, Jerry Franz wrote: > Marko Vojinovic wrote: > [...] > > > Basically, count the number of appearances of every number in your set. > > If you have a set a priori bounded from above and below --- which you do, > > [1, n^2] --- you first allocate an array of integers

Re: [CentOS] [OT] stable algorithm with complexity O(n)

2008-12-13 Thread Jerry Franz
Marko Vojinovic wrote: [...] > Basically, count the number of appearances of every number in your set. If > you > have a set a priori bounded from above and below --- which you do, > [1, n^2] --- you first allocate an array of integers of length n^2. By definition, your proposed algorithm is

Re: [CentOS] [OT] stable algorithm with complexity O(n)

2008-12-13 Thread Marko Vojinovic
> >> Hi guys, > >> > >> i am really sorry for making offtopic, hope you will not kill me, but > >> this is for me life important problem which needs to be solved within > >> next 12 hours.. > >> > >> I have to create stable algorithm for sorting n numbers from interval > >> [1,n^2] with time compl

Re: [CentOS] [OT] stable algorithm with complexity O(n)

2008-12-13 Thread Jerry Franz
David Hláčik wrote: > Well, something with linear complexity O(n) which i have to prove, > > Merge sort, Insertion sort or selection sort does not have O(n) complexity. > > I believe that something like RadixSort, CountingSort, BucketSort > altought i am not sure I'm not especially inclined to

Re: [CentOS] [OT] stable algorithm with complexity O(n)

2008-12-13 Thread David Hláčik
Well, something with linear complexity O(n) which i have to prove, Merge sort, Insertion sort or selection sort does not have O(n) complexity. I believe that something like RadixSort, CountingSort, BucketSort altought i am not sure Thanks! D. On Sat, Dec 13, 2008 at 7:51 PM, Ignacio Vazquez-Ab

Re: [CentOS] [OT] stable algorithm with complexity O(n)

2008-12-13 Thread Ignacio Vazquez-Abrams
On Sat, 2008-12-13 at 19:24 +0100, David Hláčik wrote: > Hi guys, > > i am really sorry for making offtopic, hope you will not kill me, but > this is for me life important problem which needs to be solved within > next 12 hours.. > > I have to create stable algorithm for sorting n numbers from in

[CentOS] [OT] stable algorithm with complexity O(n)

2008-12-13 Thread David Hláčik
Hi guys, i am really sorry for making offtopic, hope you will not kill me, but this is for me life important problem which needs to be solved within next 12 hours.. I have to create stable algorithm for sorting n numbers from interval [1,n^2] with time complexity O(n) . Can someone please give m