Practice30Create account

A word-and-number arrangement machine, when given an input line of words and numbers, rearranges it in steps. In each step the machine picks the largest number standing in the part of the line that is not yet fixed, and makes it trade places with whatever element occupies the first position of that not-yet-fixed part; that position then becomes fixed. Nothing else moves — the two elements simply interchange — and the machine stops once every number has been fixed.
Input: 52 opal pine 38 91 quartz 24 reed.
At which step of the above arrangement does the line "91 52 38 pine opal quartz 24 reed" appear?

Competition practiceInput-Output
  • AStep 3
  • BStep 2
  • CStep 4
  • DStep 1

Step-by-Step Solution

Step 1: 91 trades with 52, giving 91 opal pine 38 52 quartz 24 reed. Step 2: the largest loose number is 52 and the first unfixed position is 2, held by opal, so they trade: 91 52 pine 38 opal quartz 24 reed. Step 3: the largest loose number is 38 and the first unfixed position is 3, held by pine, so they trade: 91 52 38 pine opal quartz 24 reed — the line asked about. Step 4, the last, would be 91 52 38 24 opal quartz pine reed. Since 24 is still sitting in the seventh place here, the fourth interchange has not yet been made.
Answer: A) Step 3

Master this topic in 30 minutes a day.

Don't just memorise the answer — build a daily practice habit.

Practice 5 Similar Questions Free →

All Input-Output practice questions

More Input-Output practice

A word-and-number arrangement machine, when given an input line of words and numbers,…A word-and-number arrangement machine, when given an input line of words and numbers,…A word-and-number arrangement machine, when given an input line of words and numbers,…A word-and-number arrangement machine, when given an input line of words and numbers,…A word-and-number arrangement machine, when given an input line of words and numbers,…