Practice30Create account

A word-and-number arrangement machine, when given an input line of words and numbers, rearranges it in steps. In each step the leftmost word and the rightmost word, counted among the words that have not already been interchanged, trade the places they stand in. The numbers never move at all, and the machine stops when fewer than two words are left uninterchanged.
Input: 38 agra 61 kochi 27 surat 49 thane 15.
Which of the following is the last step of the above arrangement?

Competition practiceInput-Output
  • A38 thane 61 surat 27 kochi 49 agra 15
  • B38 thane 61 kochi 27 surat 49 agra 15
  • C15 agra 61 kochi 27 surat 49 thane 38
  • D38 agra 61 surat 27 kochi 49 thane 15

Step-by-Step Solution

The words are agra, kochi, surat, thane. Step 1 makes the outermost pair, agra and thane, trade places: 38 thane 61 kochi 27 surat 49 agra 15. Step 2, the last, makes kochi and surat trade places: 38 thane 61 surat 27 kochi 49 agra 15. "38 thane 61 kochi 27 surat 49 agra 15" is Step 1, one step short. "15 agra 61 kochi 27 surat 49 thane 38" interchanges the elements at the two ends of the whole line, though the numbers never move in this machine. "38 agra 61 surat 27 kochi 49 thane 15" performs only the inner interchange and leaves the outer pair alone.
Answer: A) 38 thane 61 surat 27 kochi 49 agra 15

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