The number of swaps performed by selection sort is _______ in the worst-case scenario.
- O(1)
- O(log n)
- O(n)
- O(n^2)
In the worst-case scenario, the number of swaps performed by selection sort is O(n^2). This is because, in each iteration, the algorithm selects the minimum element and swaps it with the element at the beginning, contributing to a quadratic number of swaps for a sorted array.
Loading...
Related Quiz
- What is the time complexity of the dynamic programming approach for finding the longest common subsequence?
- The time complexity of the dynamic programming solution for the coin change problem is _______.
- In some cases, the choice of compression algorithm may prioritize _______ over _______.
- How does string compression differ from regular string manipulation operations?
- Selection sort is not suitable for _______ datasets as it performs a fixed number of comparisons and swaps.