Practice30Create account

A word-and-number arrangement machine, when given an input line of words and numbers, rearranges it in steps. Only the second letter of a word matters to this machine. In each step it looks over the words still waiting, picks the one whose second letter stands nearest the beginning of the alphabet, and moves that word to the extreme right end of the line. Should two waiting words carry the same second letter, whichever of them stood nearer the right-hand end of the input goes first. Nothing else changes place, and the machine halts when no word is left waiting.
Input: 45 clover 82 chisel 19 marsh 67 thorn.
Which of the following is the last step of the above arrangement?

Competition practiceInput-Output
  • A45 82 19 67 marsh chisel thorn clover
  • B45 82 19 67 marsh thorn chisel clover
  • C45 82 19 67 clover chisel thorn marsh
  • Dmarsh thorn chisel clover 45 82 19 67

Step-by-Step Solution

Second letters: marsh gives a, chisel gives h, thorn gives h, clover gives l. Marsh goes first and clover last; between them chisel and thorn are tied on h, and the rule sends out the one standing further to the right in the input, which is thorn. Step 1: 45 clover 82 chisel 19 67 thorn marsh. Step 2: 45 clover 82 chisel 19 67 marsh thorn. Step 3: 45 clover 82 19 67 marsh thorn chisel. Step 4: 45 82 19 67 marsh thorn chisel clover. Breaking the tie the other way puts chisel before thorn and gives the first line. The third line reverses the whole finished block, and the fourth sends the words to the left end instead of the right. The numbers are never shifted, so they hold the order 45, 82, 19, 67 throughout.
Answer: B) 45 82 19 67 marsh thorn chisel clover

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