Practice30Create account

A word-and-number arrangement machine, when given an input line of words and numbers, rearranges it in steps, working the two ends of the line by turns. In every odd-numbered step the largest number not already shifted is taken out and placed at the extreme left end; in every even-numbered step the smallest number not already shifted is taken out and placed at the extreme right end. Words are never shifted, every other element keeps its relative position, and the machine stops once every number has been shifted.
Input: 34 jaipur 71 indore 28 kochi 56.
Which of the following is Step 2 of the above arrangement?

Competition practiceInput-Output
  • A71 34 jaipur indore 28 kochi 56
  • B71 34 jaipur indore kochi 56 28
  • C56 71 34 jaipur indore kochi 28
  • D28 71 34 jaipur indore kochi 56

Step-by-Step Solution

Step 1 is odd, so the largest number, 71, goes to the extreme left: 71 34 jaipur indore 28 kochi 56. Step 2 is even, so the smallest unshifted number, 28, goes to the extreme right: 71 34 jaipur indore kochi 56 28, the answer. "71 34 jaipur indore 28 kochi 56" is Step 1 and "56 71 34 jaipur indore kochi 28" is Step 3, the off-by-one steps. "28 71 34 jaipur indore kochi 56" sends the smallest number to the left end instead of the right, ignoring that the machine works the two ends by turns.
Answer: B) 71 34 jaipur indore kochi 56 28

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 arrangement machine works on an input line of words and numbers in steps. The numbers…An arrangement machine works on an input line of words and numbers in steps. The 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,…