21.1.16

Compare "robot"

Compare robot game:

The compare robot can only see two numbers at once and it has the ability to judge which number is bigger and put it to the right side. The compare robot can also walk around.

Example: If the robot sees 5, 2, it will swap them and put them into 2, 5.

If you are the compare robot, how long do you need to sort six numbers in ascending order? (1 second for any pair of numbers)


Bubble sort algorithm: A easy and good method to sort numbers with compare robot.