Courses reasoning input output
Lesson
03 of 16

🔄 Shifting Arrangement

Learn single shifting Input-Output where elements shift positions step by step to reach their sorted position, with detailed examples and position-finding techniques

Shifting Arrangement

In Shifting Arrangement, instead of picking an element and placing it at a fixed end, the machine shifts elements through the sequence. The element "bubbles" through adjacent positions until it reaches its correct spot.

This is slightly harder than Fixed because elements move through the middle of the sequence.


How Shifting Works

At each step:

  1. The machine identifies the next element to sort (e.g., the current smallest)
  2. That element shifts position by position to its correct spot
  3. Other elements shift by one position to make room
  4. This continues until the full arrangement is complete

Solved Example: Ascending Shifting

Input: 24 27 83 76 12 18 61 75

The machine sorts numbers in ascending order by shifting the smallest unsorted number to its correct position:

Step Arrangement What happened
Input 24 27 83 76 12 18 61 75 12 needs to go to position 1
Step 1 12 24 27 83 76 18 61 75 12 shifted from pos 5 to pos 1
Step 2 12 18 24 27 83 76 61 75 18 shifted from pos 6 to pos 2
Step 3 12 18 24 27 83 76 61 75 27 was already at pos 4 (minor shift)
Step 4 12 18 24 27 61 83 76 75 61 shifted to pos 5
Step 5 12 18 24 27 61 75 83 76 75 shifted to pos 6
Step 6 12 18 24 27 61 75 76 83 76 shifted to pos 7

Key difference from Fixed: In shifting, when the element moves, all elements between its old and new position shift by one. In fixed, the selected element is extracted and placed at the end while others maintain relative order.

🔐

Pro Content Locked

Upgrade to Pro to access this lesson and all other premium content.

Pro
Popular Save ₹100/mo
99 /mo
₹199

Launch prices slashed to nearly half

₹99 charged monthly · Cancel anytime

  • All Agriculture & Banking Courses
  • AI Lesson Questions (100/day)
  • AI Doubt Solver (50/day)
  • Glows & Grows Feedback (30/day)
  • AI Section Quiz (20/day)
  • 22-Language Translation (100/day)
  • Recall Questions (20/day)
  • AI Quiz (15/day)
  • AI Quiz Paper Analysis (100/day)
  • AI Step-by-Step Explanations (100/day)
  • Spaced Repetition Recall (FSRS)
  • AI Tutor
  • Immersive Text Questions
  • Audio Lessons — Hindi & English
  • Mock Tests & Previous Year Papers
  • Summary & Mind Maps
  • XP, Levels, Leaderboard & Badges
  • Generate New Classrooms
  • Voice AI Teacher (AgriDots Live)
  • AI Revision Assistant
  • Knowledge Gap Analysis
  • Interactive Revision (LangGraph)

🔒 Secure via Razorpay · Cancel anytime · No hidden fees