1.

Write a function to sort a list through insertion sorting.

Answer»

1: Iterate from arr[1] to arr[n] over the array.
2: Compare the current element (key) to its predecessor.
3: If the key element is smaller than its predecessor, compare it to the elements before. Move the greater elements one position up to make space for the swapped element.



Discussion

No Comment Found

Related InterviewSolutions