What is the time complexity of Insertion Sort in the worst-case scenario?

  • O(log n)
  • O(n log n)
  • O(n)
  • O(n^2)
The worst-case time complexity of Insertion Sort is O(n^2), where 'n' is the number of elements in the array. This is because it involves nested loops iterating over the elements, similar to bubble sort. The inner loop shifts elements until the correct position is found in the sorted subarray.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *