Insertion Sort, Algorithms, Data Structure Algorithm, Coding Interviews, Job Hunting.
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 best-case time complexity of insertion sort is O(n). Worst case complexity: As discussed earlier, in the worst case our