wu :: forums
« wu :: forums - Finding a Permutation »

Welcome, Guest. Please Login or Register.
May 6th, 2024, 9:37am

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: SMQ, william wu, ThudnBlunder, Eigenray, Icarus, towr, Grimbal)
   Finding a Permutation
« Previous topic | Next topic »
Pages: 1 2  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: Finding a Permutation  (Read 3244 times)
Dudidu
Full Member
***





   


Posts: 227
Re: Finding a Permutation  
« Reply #25 on: Nov 5th, 2003, 10:25am »
Quote Quote Modify Modify

Barukh, let me help you a little Wink.
Lets recap what we have on the 2nd question (e.g. the "follower"):
As you suggested, we divided the set of numbers into n2 bins. Every time that we have "transfered" a number into bini, we added an element with a key valued i to the list (e.g. set) of bins that are in use. At the end of this stage we have bins that hold the all the initial numbers (lets forget about them) and a list of the bins that are in use. So practically, we have reduced the initial problem to the problem of sorting a list/array of size n that holds numbers (maybe duplicate) from the range of {0, ..., n2-1}.
So...
Barukh, now it's your turn to complete the algorithm.
« Last Edit: Nov 5th, 2003, 10:26am by Dudidu » IP Logged
Barukh
Uberpuzzler
*****






   


Gender: male
Posts: 2276
Re: Finding a Permutation  
« Reply #26 on: Nov 6th, 2003, 2:22am »
Quote Quote Modify Modify

on Nov 5th, 2003, 10:25am, Dudidu wrote:
So ... we have reduced ... to the problem of sorting a list/array of size n that holds numbers (maybe duplicate) from the range of {0, ..., n2-1}.

Yes, I got it. And what is most obvious way to do it (at least for me)? Radix sort!  Grin
IP Logged
Dudidu
Full Member
***





   


Posts: 227
Re: Finding a Permutation  
« Reply #27 on: Nov 6th, 2003, 3:22am »
Quote Quote Modify Modify

on Nov 6th, 2003, 2:22am, Barukh wrote:
Yes, I got it. And what is most obvious way to do it (at least for me)? Radix sort!  Grin
There is another way to do it that uses counting sort (http://www.nist.gov/dads/HTML/countingsort.html)... but nevermind (it seems that this question has already been "pushed to the limit" Wink).
 
 
IP Logged
DH
Newbie
*






   


Gender: male
Posts: 19
Re: Finding a Permutation  
« Reply #28 on: Nov 6th, 2003, 5:39am »
Quote Quote Modify Modify

on Nov 6th, 2003, 3:22am, Dudidu wrote:

There is another way to do it that uses counting sort (http://www.nist.gov/dads/HTML/countingsort.html)... but nevermind (it seems that this question has already been "pushed to the limit" Wink).
 
 

 
Let's push the limit a little further Smiley
 
I think this is O(n^2) because you are sorting numbers in the range 0..n^2-1.
IP Logged
Dudidu
Full Member
***





   


Posts: 227
Re: Finding a Permutation  
« Reply #29 on: Nov 6th, 2003, 6:06am »
Quote Quote Modify Modify

on Nov 6th, 2003, 5:39am, DH wrote:
I think this is O(n^2) because you are sorting numbers in the range 0..n^2-1.

DH, please pay attention that I wrote "uses counting sort", so counting sort is not a "stand alone" procedure to answer this problem. However, I must admit Undecided that the this solution uses ideas taken from the radix sort (So, some may say that this is an extension of radix sort).
Sorry if this was misleading...
 
 
IP Logged
Barukh
Uberpuzzler
*****






   


Gender: male
Posts: 2276
Re: Finding a Permutation  
« Reply #30 on: Nov 6th, 2003, 11:20am »
Quote Quote Modify Modify

on Nov 6th, 2003, 5:39am, DH wrote:
Let's push the limit a little further Smiley.

And let me push it further still  Grin
 
Using the radix sort idea, it is possible in linear time to deliver a permutation with the sum of absolute differences [le] 1 + 1/nk for every constant k.
 
An amazing problem!
« Last Edit: Nov 6th, 2003, 11:21am by Barukh » IP Logged
Pages: 1 2  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board