Fine, Java MIGHT be a good example of what a programming language should be like. But Java applications are good examples of what applications SHOULDN’T be like. pixadel

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.

Output

          	        
          	        

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

          	        
          	        				    


Comments



Please login to add comments.