Practice30Create account

A word-and-number arrangement machine, when given an input line of words and numbers, rearranges it in steps. In each step two elements trade the places they stand in: the largest number not already shifted, and the word that comes first in alphabetical order among the words not already shifted. Nothing else moves, and the machine stops as soon as either no unshifted number or no unshifted word is left.
Input: 39 tabla 72 dholak 56 veena 18.
How many steps are needed to complete the rearrangement of the above input?

Competition practiceInput-Output
  • A4
  • B3
  • C2
  • D7

Step-by-Step Solution

Step 1 makes 72 (largest number) trade places with dholak (alphabetically first word): 39 tabla dholak 72 56 veena 18. Step 2 makes 56 trade places with tabla: 39 56 dholak 72 tabla veena 18. Step 3 makes 39 trade places with veena: veena 56 dholak 72 tabla 39 18. Now 18 is the only unshifted number and no unshifted word is left, so the machine stops after 3 steps. "4" assumes 18 can also be shifted, but it has no word left to trade with. "2" stops before the third trade. "7" counts one step per element of the line.
Answer: B) 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,…An input-output arrangement machine rearranges a line of words and numbers one step at a…An input-output arrangement machine rearranges a line of words and numbers one step at a…An arrangement machine works on an input line of words and numbers in steps. In each…A word-and-number arrangement machine, when given an input line of words and numbers,…