i've noticed every comparison sorting algorithm relies on comparing only 2 objects. but it seems to me a ternary algorithm should also be possible.
for example consider a three way balance scale. you put objects in each of the three levers, and based on the results of the levers, you can tell which objects are heavier or lighter. for example, let's say you put 10, 15, and 20 in the scale. the 20 will be down the most, 10 will be the highest, and 15 will be medium.
assume you had such a function, lets call it tri(a,b,c) which returns them in the proper order. write an efficient sorting algorithm.
Question
Guest
i've noticed every comparison sorting algorithm relies on comparing only 2 objects. but it seems to me a ternary algorithm should also be possible.
for example consider a three way balance scale. you put objects in each of the three levers, and based on the results of the levers, you can tell which objects are heavier or lighter. for example, let's say you put 10, 15, and 20 in the scale. the 20 will be down the most, 10 will be the highest, and 15 will be medium.
assume you had such a function, lets call it tri(a,b,c) which returns them in the proper order. write an efficient sorting algorithm.
Link to comment
Share on other sites
19 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.