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 shifts happen together: the smallest odd number not already shifted is taken out and placed at the extreme left end of the line, and at the same time the largest even number not already shifted is taken out and placed at the extreme right end. If only one of the two kinds is still left, that step makes only that one shift. Every other element keeps its relative position, and the machine stops once every number has been shifted.
Input: 46 tulip 23 marsh 58 clover 31 birch.
Which of the following is Step 1 of the above arrangement?

Competition practiceInput-Output
  • A23 46 tulip marsh 58 clover 31 birch
  • B31 46 tulip 23 marsh clover birch 58
  • C23 tulip marsh 58 clover 31 birch 46
  • D23 46 tulip marsh clover 31 birch 58

Step-by-Step Solution

The odd numbers are 23 and 31, the even ones 46 and 58. In Step 1 the smallest odd number, 23, goes to the extreme left and the largest even number, 58, goes to the extreme right, both in the same step: 23 46 tulip marsh clover 31 birch 58. Moving only the odd number leaves 58 in mid-line; taking the largest odd number instead of the smallest opens the line with 31; and taking the smallest even number rather than the largest sends 46 to the right end and leaves 58 stranded.
Answer: D) 23 46 tulip marsh clover 31 birch 58

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