To optimize bubble sort, one can implement a _______ that stops iterating when no more swaps are needed.

  • Binary search
  • Flag-based check
  • Hash table
  • Recursive function
To optimize bubble sort, one can implement a flag-based check that stops iterating when no more swaps are needed. This optimization helps in breaking out of the loop early if the array is already sorted, reducing unnecessary iterations and improving the overall efficiency of the algorithm.
Add your answer
Loading...

Leave a comment

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