StudentSquare.in

Insertion Sort


Detailed Discussion


1)What is Insertion Sort ?
  Insertion sort is the sorting mechanism where the sorted array is built having one item at a time. The array elements are compared with each other sequentially and then arranged simultaneously in some particular order.

The array is searched sequentially and unsorted items are moved and inserted into the sorted sub-list (in the same array).

2)What is the complexity of Insertion Sort ?
  Time Complexity of average and worst case are of Ο(n^2) where n is the number of items.

3)Why it is called Insertion Sort ?
  This is an in-place comparison-based sorting algorithm. Here, a sub-list is maintained which is always sorted. For example, the lower part of an array is maintained to be sorted. An element which is to be 'insert'ed in this sorted sub-list, has to find its appropriate place and then it has to be inserted there. Hence the name, insertion sort.

2)What is the disadvantage of Insertion Sort ?
  This algorithm is not suitable for large data sets as its average and worst case complexity are of Ο(n2), where n is the number of items.