wu :: forums
« wu :: forums - sort array containing only 3 type of elements »

Welcome, Guest. Please Login or Register.
Nov 23rd, 2024, 9:45pm

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   microsoft
(Moderators: Icarus, towr, SMQ, Grimbal, william wu, ThudnBlunder, Eigenray)
   sort array containing only 3 type of elements
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   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 Quote Modify 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: male
Posts: 13730
Re: sort array containing only 3 type of elements  
« Reply #1 on: Dec 3rd, 2008, 2:08am »
Quote Quote Modify 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
Pages: 1  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