The best programmers are not marginally better than merely good ones. They are an order-of-magnitude better, measured by whatever standard: conceptual creativity, speed, ingenuity of design, or problem-solving ability. Randall E. Stross

Insertion sort

Language Java | Level Intermediate | Category Algorithms | August 2, 2015 8:55 pm

Algorithm Problem Description

Insertion sort is a simple sorting algorithm that builds sorted array one item at a time. It is efficient for the small data set.

Insertion sort is best suitable for nearly sorted arrays and the small set of elements. It is similar to selection sort. The selection sort must scan all the elements to find the smallest element. But the insertion sort scans only the remaining elements in the array. The insertion sort can combine with divide and conquer based algorithm for better optimization.

Write a program to implement the insertion sort.



Unsorted array before sorting: [12, 34, 56, 23, 45, 78, 46]
Sorted array After Insertion Sort sorting: [12, 23, 34, 45, 46, 56, 78]



Please login to add comments.