Practice30Create account

A number-arranging machine rearranges a line of numbers step by step. In each step it moves the smallest of the not-yet-arranged numbers to the extreme left and the largest of the not-yet-arranged numbers to the extreme right, while the remaining numbers keep their relative order. Input line: 3 7 2 9 5 1. How many steps are needed to arrange the whole line into ascending order?

Competition practiceInput-Output
  • AFour
  • BTwo
  • CThree
  • DOne

Step-by-Step Solution

Step I: 1 3 7 2 5 9. Step II places the next smallest (2) after 1 and the next largest (7) before 9, giving 1 2 3 5 7 9, which is fully ascending. Two steps are required.
Answer: B) Two

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 rearranges an input line in steps. In each step…A word-and-number arrangement machine rearranges an input line in steps. In each step…A rearrangement machine works in steps. In each step it picks the word that comes…A word-and-number arrangement machine, given an input line, rearranges it by a fixed…A word-and-number arrangement machine, given an input line, rearranges it by a fixed…