Worst Bubbles

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:


The answer is 6.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

0 solutions

No explanations have been posted yet. Check back later!

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...