An Initiative by SAARTHI IAS
Maarg Manthan · Topic 17.1

Number-Based Input-Output Rearrangement (Ascending/Descending Order)

Reasoning › Input-Output · Topic 17.1

In number-based input-output problems, a machine rearranges a line of numbers step by step using one fixed rule, such as moving the largest remaining number to the left end, until the numbers are in ascending or descending order. Find the rule from the first step, apply it to later steps, and note that n numbers need at most n - 1 steps.

Share:
Number-Based Input-Output Rearrangement (Ascending/Descending Order) - Reasoning - MaargX UPSC Maarg Manthan

Quick Answer

In number-based input-output problems, a machine rearranges a line of numbers step by step using one fixed rule, such as moving the largest remaining number to the left end, until the numbers are in ascending or descending order. Find the rule from the first step, apply it to later steps, and note that n numbers need at most n – 1 steps.

At a Glance

  • Input A line of numbers
  • Rule One number is moved per step
  • Descending build Largest remaining goes to the left
  • Ascending build Smallest remaining goes to the left, or largest to the right
  • Maximum steps n – 1 for n numbers
  • Others Keep their relative order

Where Does It Fit?

This is the first topic of the input-output macro. It uses numbers only. Words follow in Word-Based Input-Output Rearrangement (Alphabetical Order), mixed lines in Mixed Word-Number Input-Output Problems, and finding the step number in Identifying the Step Number at Which a Given Arrangement Is Achieved.

What Rules Do Number Machines Use?

In short: in each step the machine picks one number by size and moves it to the next free place at an end of the line; all other numbers keep their relative order.

Rule Each step Final order
Largest to the left Largest remaining number moves to the next free place from the left Descending
Smallest to the left Smallest remaining number moves to the next free place from the left Ascending
Largest to the right Largest remaining number moves to the next free place from the right Ascending
Smallest to the right Smallest remaining number moves to the next free place from the right Descending

In a number-based rearrangement, take the input 14 57 48 92 93 28 with the rule “largest to the left”; the largest number is 93. Step I moves 93 to the left end. Step II moves the largest of the rest, 92, to the second place. Each step fixes one more number, so the line is sorted after at most five steps.

  • Others keep order: in every step the numbers not yet fixed stay in their earlier relative order.
  • Fixed block: the numbers already placed form a block at one end and never move again.
  • Early finish: if the tail is already in order, the line is complete before step n – 1.

How Do You Find the Rule From a Given Example?

In short: compare the input with Step I, see which number moved and where it went, and confirm with Step II.

  1. Compare input and Step I. Find the one number whose position changed most.
  2. Check size. Is that number the largest or the smallest?
  3. Check the end. Did it move to the left end or the right end?
  4. Confirm with Step II. The second number moves next to the first.
  5. Apply the rule to the new input, one step at a time.

Counting

  • Steps needed = n – 1 at most.
  • The last number is placed automatically with the previous step.
  • A step may look unchanged when the chosen number is already in its place.

Methods for identifying more complex rules appear in Identifying the Underlying Rule of an Input-Output Machine from a Given Example.

Which Mistakes Do Candidates Make?

In short: most mistakes come from reordering the other numbers or from choosing the wrong end.

  • Sorting everything at once: only one number moves per step.
  • Wrong end: moving the largest to the right when the rule says left.
  • Counting the repeated step: a step that looks the same as the one before still counts as a step.

Solved Examples

Example 1

Question: Input: 14 57 48 92 93 28. In each step, the largest of the numbers not yet placed is moved to the next free place from the left, and the other numbers keep their order. What is Step III?

  1. Step I: 93 is the largest, so it goes to the left end. The line is 93 14 57 48 92 28.
  2. Step II: 92 is the largest of the rest, so it goes to the second place. The line is 93 92 14 57 48 28.
  3. Step III: 57 is the largest of the rest, so it goes to the third place. The line is 93 92 57 14 48 28.

Answer: Step III is 93 92 57 14 48 28. The remaining steps give 93 92 57 48 14 28 and 93 92 57 48 28 14.

Example 2

Question: Input: 45 12 78 23 56 34. In each step, the largest of the numbers not yet placed is moved to the next free place from the right. How many steps are needed to finish?

  1. Step I: 78 goes to the right end. The line is 45 12 23 56 34 78.
  2. Step II: 56 is the largest of the rest and goes to the second place from the right. The line is 45 12 23 34 56 78.
  3. Step III: 45 is the largest of the rest and goes to the third place from the right. The line is 12 23 34 45 56 78.
  4. The line is now in ascending order, and further steps change nothing.

Answer: 3 steps are needed.

Example 3

Question: Input: 72 18 45 63 27 54. In each step, the smallest of the numbers not yet placed is moved to the next free place from the left. What is Step IV, and which step is the last?

  1. Step I: 18 goes first, giving 18 72 45 63 27 54.
  2. Step II: 27 goes second, giving 18 27 72 45 63 54.
  3. Step III: 45 goes third, giving 18 27 45 72 63 54.
  4. Step IV: 54 goes fourth, giving 18 27 45 54 72 63.
  5. Step V: 63 goes fifth, giving 18 27 45 54 63 72, which is ascending.

Answer: Step IV is 18 27 45 54 72 63, and Step V is the last.

Example 4

Question: In the first example, which number is in the 4th place from the left in Step II?

  1. Step II is 93 92 14 57 48 28.
  2. The fourth number is 57.

Answer: 57.

Example 5

Question: In the first example, how many numbers are already in their final places after Step III?

  1. Step III is 93 92 57 14 48 28 and the final line is 93 92 57 48 28 14.
  2. The first three places match. The fourth to sixth do not.

Answer: 3 numbers are in their final places.

Shortcuts and Tricks

  • Write the sorted order of the whole input first. It tells you what each step will place.
  • Copy the unchanged tail of the previous line and change only the front.
  • Remember: one number moves per step, and the others keep their order.
  • A tail that is already in order can shorten the step count.
  • For a question about the final step, sort the input and read it off.

Common Mistakes

  • Moving more than one number in a step.
  • Changing the order of the unplaced numbers.
  • Mixing up left and right ends.
  • Skipping a step that looks unchanged.
  • Counting the input as Step I.

Practice Questions

  1. Input: 26 71 43 58. Each step moves the largest remaining number to the next free place from the left. What is Step II?
  2. What is the maximum number of steps needed to sort 6 numbers by moving one number per step?
  3. Input: 63 28 91 45. Each step moves the smallest remaining number to the next free place from the left. What is Step II?
  4. Input: 35 82 17 64. Each step moves the largest remaining number to the next free place from the right. In which step is the line 17 35 64 82 obtained?
  5. What is the maximum number of steps needed to sort 8 numbers by this method?

Answers: 1) 71 58 26 43; 2) 5; 3) 28 45 63 91; 4) Step III; 5) 7.

Why Is This Topic Important?

  • Exam frequency A number machine appears in the prelims of most bank exams.
  • Skill It trains the habit of reading a rule from a short example.
  • Speed Questions on later steps can be done from the sorted order without writing all steps.
  • Link The same step reading is used for words in Word-Based Input-Output Rearrangement (Alphabetical Order).

What Comes Next?

The next topic is Word-Based Input-Output Rearrangement (Alphabetical Order). It uses the same step logic with words arranged in alphabetical order.

Key Terms and Formulas

  • Input The starting line
  • Step One application of the rule
  • Fixed block Numbers already placed at an end
  • Ascending Smallest to largest
  • Descending Largest to smallest
  • Rule The repeated instruction

Exam Corner

Points to Remember

  • One number moves per step.
  • The other numbers keep their relative order.
  • At most n – 1 steps for n numbers.
  • Compare input and Step I to find the rule.
  • The input itself is not a step.

Do Not Confuse With

  • Left build vs right build Left build fixes the left end first; right build fixes the right end first.
  • Largest left vs smallest right Both give a descending order.
  • Step vs line A step is an action; the line is its result.
  • Sorted vs complete A line may be sorted before the last step is reached.

Memory Hook

One move per step, others keep their order, the placed block grows.

GS Relevance

Input-output machine questions appear in IBPS PO prelims, SBI PO and SSC reasoning as 5 questions on a single input line and its steps.

Frequently Asked Questions

How do you solve number-based input-output questions?

Compare the input with Step I to see which number moved, check whether it was the largest or smallest and to which end it went, and confirm with Step II. Then apply the same rule to the new input one step at a time, keeping the other numbers in their previous order.

How many steps does an input-output machine need?

A machine that fixes one number per step needs at most n minus 1 steps for n numbers, because the last number is placed automatically. It may finish earlier if the numbers at the other end are already in order, as in an input where the tail is already sorted.

Do the other numbers change order in each step?

No. In a standard input-output rule only the chosen number moves, and all the other numbers keep their relative order. The fixed block at one end grows by one number in every step, while the rest of the line is shifted without reordering.

What is the difference between left build and right build?

Left build places the chosen numbers from the left end onwards, while right build places them from the right end backwards. Moving the smallest to the left and moving the largest to the right both produce an ascending line, but they differ in the intermediate steps.

How can I answer questions about a later step quickly?

Sort the whole input first. In a left-build rule the first k numbers of Step k are the k largest or smallest numbers in order, and the rest stay in their original order. This lets you write the required step directly without all earlier steps.

PYQ Practice — Statement Analysis

1 In a one-number-per-step machine, sorting n numbers needs at most n - 1 steps.
True

The last number is placed automatically when the others are fixed.

2 In each step all numbers are reordered.
False

Only one number moves; the others keep their relative order.

3 Moving the largest number to the left each step gives a descending line.
True

The placed block on the left is in descending order.

4 The given input is counted as Step I.
False

The input is the starting line; Step I is the first result.

Share: