Selection sort's time complexity remains _______ regardless of the input sequence.
- O(log n)
- O(n log n)
- O(n)
- O(n^2)
The time complexity of selection sort is O(n^2), and it remains the same regardless of the input sequence. This is because it involves nested loops to iterate over the elements for comparisons and swaps, resulting in quadratic time complexity.
Loading...
Related Quiz
- BFS guarantees finding the shortest path in an unweighted graph because it explores nodes in _______ order.
- Which of the following sorting algorithms is similar to selection sort in terms of repeatedly finding the minimum element from the unsorted portion and placing it at the beginning?
- Recursive implementation of binary search involves breaking the problem into _______ subproblems until a solution is found.
- One of the key advantages of merge sort is its _______ time complexity in all cases.
- How does BFS differ from Depth-First Search (DFS)?