wu :: forums
« wu :: forums - One pass sort »

Welcome, Guest. Please Login or Register.
Apr 23rd, 2024, 4:51am

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: Grimbal, towr, ThudnBlunder, Eigenray, Icarus, william wu, SMQ)
   One pass sort
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: One pass sort  (Read 2843 times)
sateesp
Newbie
*





   


Gender: male
Posts: 35
One pass sort  
« on: Jul 28th, 2010, 10:46pm »
Quote Quote Modify Modify

Given an array with consists of 0's, 1's and 2's only in random order.
 
Can we sort this array in one pass?
IP Logged
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: One pass sort  
« Reply #1 on: Jul 29th, 2010, 2:47am »
Quote Quote Modify Modify

Yes. It's known as http://en.wikipedia.org/wiki/Dutch_national_flag_problem
 
See also  
http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi?board=riddles_cs; action=display;num=1100111371
http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi?board=riddles_cs; action=display;num=1197342769
http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi?board=riddles_cs; action=display;num=1231090929
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
birbal
Full Member
***





   


Gender: male
Posts: 250
Re: One pass sort  
« Reply #2 on: Jul 29th, 2010, 11:21am »
Quote Quote Modify Modify

Save begining for 0's , ending for 2's , then you automatically have all 1's in the middle.
Its sorted Smiley
IP Logged

The only thing we have to fear is fear itself!
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