What is the time complexity of the bubble sort algorithm in the best case?
- O(1)
- O(log n)
- O(n)
- O(n^2)
The best-case time complexity of the bubble sort algorithm is O(n) when the array is already sorted, and no swaps are required during the pass.
Loading...
Related Quiz
- How can using pointers to structures optimize memory usage in a C program?
- When defining a bit field, what does the number after the colon represent?
- The preprocessor directive ________ is used to include libraries in a C program.
- Why might you choose to use an enumeration instead of a series of #define statements for constants?
- What happens if you try to modify a character in a string literal?