Bubble sort's time complexity can be improved to _______ by implementing certain optimizations.

  • O(n log n)
  • O(n log^2 n)
  • O(n)
  • O(n^2)
Bubble sort's time complexity can be improved to O(n) by implementing certain optimizations. With optimized versions such as the flag-based check and other enhancements, the algorithm can achieve linear time complexity in scenarios where the array is already sorted or nearly sorted, making it more efficient in specific use cases.
Add your answer
Loading...

Leave a comment

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