Skip to content

Latest commit

 

History

History

Minimum Insertions to Sort An Array

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Given an array of integer numbers, we need to sort this array in a minimum number of steps where in one step we can insert any array element from its position to any other position.

Input  : arr[] = [2, 3, 5, 1, 4, 7, 6]
Output : 3
We can sort above array in 3 insertion 
steps as shown below,
1 before array value 2
4 before array value 5
6 before array value 7

Input : arr[] = {4, 6, 5, 1}
Output : 2