Author |
Topic: sort array containing only 3 type of elements (Read 5354 times) |
|
sanny
Newbie
Posts: 6
|
|
sort array containing only 3 type of elements
« on: Dec 3rd, 2008, 1:13am » |
Quote Modify
|
sort the array containg only 3 type of elements randomly distributed, without using extra space ( i.e, no bucket sort ) in O(n) time. Eg. input A= {0,1,1,2,1,0,0,2,2,0,1,1,2,0} output A= {0,0,0,0,0,1,1,1,1,1,2,2,2,2}
|
|
IP Logged |
|
|
|
towr
wu::riddles Moderator Uberpuzzler
Some people are average, some are just mean.
Gender:
Posts: 13730
|
|
Re: sort array containing only 3 type of elements
« Reply #1 on: Dec 3rd, 2008, 2:08am » |
Quote Modify
|
A (very much) older thread on this problem can be found here. (There should be more recent ones as well, but I haven't been able to find the right keywords to search for them)
|
|
IP Logged |
Wikipedia, Google, Mathworld, Integer sequence DB
|
|
|
|