you are here->home->Class 12->Insertion Sort
Insertion Sort


Real Lab Procedure 

  1. The list is virtually split into a sorted and an unsorted part.  Value from the unsorted part is  picked and placed at the correct position in the sorted part.  
  2. It stores the elements to be sorted in a list named "arr". 
  3. Assuming that the first element (at location 1) is already sorted.  
  4. Pick the next element and store it separately in a "key".  
  5. Compare the "key" with all elements in the sorted list.  
  6. If the element in the sorted list is smaller than the current element, then move to the next element. else, shift greater elements in the list towards the right.  
  7. Insert the "key" at proper location.  
  8. Repeat steps 4, 5 and 6 until the list becomes sorted.  
  9. Print the sorted list. 

Simulator Procedure

  • Select the variables from the dropdown list.
  • Click on the Finish button or Start button to view the state diagram.
  • If you have clicked on the Start button then use Next and Previous button to view the State diagram.
  • Click on the Reset button when the State diagram is completed.