Practice30Create account

An arrangement machine reshuffles an input line by interchanging one pair of elements per step. In Step 1 it interchanges the elements standing at the 1st and the last positions, in Step 2 those at the 2nd and the second-last positions, in Step 3 those at the 3rd and the third-last positions, and so on. Nothing is ever taken out of the line — the two elements simply trade places — and the machine stops when no untouched pair is left to interchange.
Input: 19 oak 56 pier 32 quill 74.
At which step of the above arrangement does the line "74 quill 56 pier 32 oak 19" appear?

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

Step-by-Step Solution

Seven elements, so the pairs are (1,7), (2,6) and (3,5); position 4, held by pier, is never disturbed. Step 1: 74 oak 56 pier 32 quill 19. Step 2: 74 quill 56 pier 32 oak 19 — the line asked about. Step 3, the last, would be 74 quill 32 pier 56 oak 19, with 56 and 32 having changed places. Since 56 and 32 are still in their original spots here, the third swap has not yet happened.
Answer: C) Step 2

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,…