The worst-case time complexity of bubble sort is _______.
- O(log n)
- O(n log n)
- O(n)
- O(n^2)
The worst-case time complexity of bubble sort is O(n^2), where 'n' is the number of elements in the array. This is due to the nested loops that iterate over the elements, making it inefficient.
Loading...
Related Quiz
- Discuss the space complexity of merge sort and how it compares to other sorting algorithms.
- Describe the process of reversing a linked list iteratively and recursively.
- What is the time complexity of the brute-force approach for finding the Longest Palindromic Substring?
- Consider a scenario where you need to find the nth Fibonacci number in real-time for multiple concurrent requests. Describe how you would architect a solution to handle this efficiently, considering both time and space complexities.
- When encountering cycles in a graph, BFS _______ revisits already visited nodes.