TECHNOLOGIESTieInn Technologies

Input-output

Input-output: a step-by-step sorting machine

6 min read · 8 practice questions · free

Useful for:Banks

What it is

Bank papers show a "machine" that rearranges a line of numbers or words step by step, with an input and a few steps as an example. You work out the rule and answer questions like "What is Step 3?" or "How many steps to finish?"

Here the rule is: at each step, the smallest number not yet placed moves to just after the numbers already placed; the rest keep their order.

How to solve it

  1. Find the rule from the example (or read it, as here).
  2. Apply it one step at a time, writing each step out in full.
  3. Count the steps if asked. The machine stops when the line is in order.

Tips and shortcuts

  • Only one number moves per step. Everything else keeps its relative order.
  • Write each step under the last, so a slip is easy to spot.
  • The last step may come early: if the line is already in order, nothing moves.
  • Words work the same way, with dictionary order instead of size.

Solved examples

Example 1 (easy)

Input: 45 12 78 33 60. Step 1?

The smallest, 12, moves to the front: 12 45 78 33 60.

Example 2 (medium)

Same input. Step 2?

The smallest of the rest, 33, moves just after 12: 12 33 45 78 60.

Example 3 (hard)

Same input. Step 3?

The next smallest, 45, is already in place, so nothing moves: 12 33 45 78 60.

Example 4 (hard)

Same input. Step 4?

60 moves before 78: 12 33 45 60 78. Now the line is in order.

Example 5 (medium): how many steps

For input 25 10 40 15, how many steps until it is sorted?

Step 1: 10 25 40 15. Step 2: 10 15 25 40 (sorted). 2 steps.

Try it

Pick an answer and press Check. Generated questions get new numbers every time you ask.

  1. Question 1easy

    A machine rearranges numbers step by step. At each step it picks the smallest number not yet placed and moves it just after the numbers already placed (keeping the rest in order).

    Input: 53 75 47 55 71 31

    What is Step 1?

  2. Question 2easy

    A machine rearranges numbers step by step. At each step it picks the smallest number not yet placed and moves it just after the numbers already placed (keeping the rest in order).

    Input: 41 87 53 39 23 89

    What is Step 1?

  3. Question 3easy

    A machine rearranges numbers step by step. At each step it picks the smallest number not yet placed and moves it just after the numbers already placed (keeping the rest in order).

    Input: 41 81 79 71 57 15

    What is Step 1?

  4. Question 4medium

    A machine rearranges numbers step by step. At each step it picks the smallest number not yet placed and moves it just after the numbers already placed (keeping the rest in order).

    Input: 69 35 85 61 49 59

    What is Step 2?

  5. Question 5medium

    A machine rearranges numbers step by step. At each step it picks the smallest number not yet placed and moves it just after the numbers already placed (keeping the rest in order).

    Input: 21 53 45 57 35 25

    What is Step 2?

  6. Question 6medium

    A machine rearranges numbers step by step. At each step it picks the smallest number not yet placed and moves it just after the numbers already placed (keeping the rest in order).

    Input: 63 13 37 77 43 85

    What is Step 2?

  7. Question 7hard

    A machine rearranges numbers step by step. At each step it picks the smallest number not yet placed and moves it just after the numbers already placed (keeping the rest in order).

    Input: 55 63 37 53 51 35

    What is Step 3?

  8. Question 8hard

    A machine rearranges numbers step by step. At each step it picks the smallest number not yet placed and moves it just after the numbers already placed (keeping the rest in order).

    Input: 61 89 53 27 25 73

    What is Step 3?

Ready for a timed set?

Fresh questions on just this problem type, with a score and every explanation at the end. Free.

Test me on this →