Jump to content


- - - - -

sort 4 elements with 3 comparisons (not a homework question)


2 replies to this topic

#1 Mihail121

    Senior Member

  • Members
  • PipPipPipPip
  • 1059 posts

Posted 17 January 2009 - 03:55 PM

Now I've had a friend over telling me one could sort 4 elements (balls for ex.) using 3 measurments with a standard scale. I tried and tried and TRIED but I just can't do it. Does anyone have an idea how would it be possible?

#2 Nils Pipenbrinck

    Senior Member

  • Members
  • PipPipPipPip
  • 597 posts

Posted 17 January 2009 - 06:43 PM

It's not possible. The minimum number of compare and swap-operations you need is five (assuming the data is not already partly sorted).
My music: http://myspace.com/planetarchh <-- my music

My stuff: torus.untergrund.net <-- some diy electronic stuff and more.

#3 Sol_HSA

    Senior Member

  • Members
  • PipPipPipPip
  • 510 posts
  • LocationNowhere whenever

Posted 17 January 2009 - 08:46 PM

Depends on how you define measurements. spaghetti sort could definitely do it.. =)
http://iki.fi/sol - my schtuphh





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users