Question:

From one sequence of digits, another sequence of digits has to be formed as per the following rule:
Random switch: interchange of any two digits, regardless of where they sit in the sequence, where one such interchange counts as one step.

Using only random switching, what is the minimum number of steps required to change 653124 to 123456?

Show Hint

Trace the closed loops the digits must travel through. The minimum number of swaps equals the digit count in each loop minus one, added up across all loops.
Updated On: Jul 15, 2026
  • 3
  • 4
  • 5
  • None of these
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

Step 1: Trace where each digit needs to go.
Start with 6 5 3 1 2 4 at positions 1 to 6, target 1 2 3 4 5 6. Position 1 holds 6, which belongs at position 6. Position 6 holds 4, which belongs at position 4. Position 4 holds 1, which belongs at position 1. This closes a loop through positions 1, 6 and 4. Separately, position 2 holds 5, which belongs at position 5, and position 5 holds 2, which belongs at position 2, closing a second loop through positions 2 and 5. Position 3 already holds the correct digit, 3, and forms a loop of its own.

Step 2: Turn the loops into a step count.
A closed loop covering $k$ positions can always be sorted in $k - 1$ swaps when any two positions can be swapped directly, and never in fewer. The 3 position loop (1, 6, 4) needs 2 swaps, the 2 position loop (2, 5) needs 1 swap, and the 1 position loop (3) needs 0 swaps. Total minimum steps:
\[ 2 + 1 + 0 = 3 \]

Step 3: Confirm with an actual sequence of swaps.
Swap positions 1 and 4 (values 6 and 1): 6 5 3 1 2 4 becomes 1 5 3 6 2 4.
Swap positions 2 and 5 (values 5 and 2): 1 5 3 6 2 4 becomes 1 2 3 6 5 4.
Swap positions 4 and 6 (values 6 and 4): 1 2 3 6 5 4 becomes 1 2 3 4 5 6.
The target is reached in exactly 3 steps.

Final Answer:
The minimum number of random switch steps needed is 3. \[ \boxed{3} \]
Was this answer helpful?
0
0