Insertion sort

Insertion sort is another simple sorting algorithm that builds the final sorted array one element at a time. It iterates through the list and repeatedly inserts each unsorted element into its correct position in the already sorted part of the array. Here’s how the basic insertion sort algorithm works: Now, let’s illustrate this with a…