There are 6 students standing in a queue, in some order. They want to arrange themselves according to their height, following the algorithm below:

- In phase 1, every student in odd positions swaps places with the student in front if the one in front is taller.
- In phase 2, every student in even positions swaps places with the student in front if the one in front is taller.
- Both phases are repeated alternately until everybody observes that the student in front is shorter than themselves.

What is the *maximum* number of rounds it could take for them to sort themselves?

For example, if they were initially arranged in the reverse order (654321), it would take 6 rounds of these swaps for the students to sort themselves to the desired arrangement (123456), as shown in the animation:

×

Problem Loading...

Note Loading...

Set Loading...