Sorting Algorithms, Insertion Sort, Algorithms, Dsa Courses, Dsa Training.
sort will be when we have a sorted array. Suppose we have an array as 1 2 3 4 5. In this case, we will compare 2 with 1, no swapping will take place. Then we compare 3 with 2, again no swapping will be done. Similarly in the end, total no. of comparisons will be 1 + 1 + 1 … = n-1. Therefore, the