Question: Write a program that reads four numbers from the standard input and sorts them in ascending order . You can base your program on the

Write a program that reads four numbers from the standard input and sorts them in ascending order. You can base your program on the program Sort3Numbers.java for sorting three numbers that is given in class. (If you indeed base your program on Sort3Numbers.java, you can use the exact code therein and need just three more comparisons in order to sort four numbers.) Or you can come up with your own method for solving the problem. In order to receive full credit, your program must use no more than six comparisons. You will receive extra credit if your program uses only five comparisons, and for that you do need to come with different ideas. (It also turns out that five comparisons is the best possible for sorting four numbers.)

must be written in java

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!