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: patna 45 ujjain 82 salem 19 thane 63.
In the last step of the above arrangement, which element is third from the left end?

Competition practiceInput-Output
  • A82
  • Bujjain
  • C45
  • Dpatna

Step-by-Step Solution

Step 1 (odd): 82 patna 45 ujjain salem 19 thane 63. Step 2 (even): 82 patna 45 ujjain salem thane 63 19. Step 3 (odd): 63 82 patna 45 ujjain salem thane 19. Step 4 (even, last): 63 82 patna ujjain salem thane 19 45. Counting from the left — 63, 82, patna — the third element is patna. "82" is second from the left. "ujjain" is fourth, the answer got by counting one place too far. "45" is third from the RIGHT end of the last step, not from the left.
Answer: D) patna

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

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,…A word-and-number arrangement machine, when given an input line of words and numbers,…