What is the time complexity of the selection sort algorithm in the worst-case scenario?
- O(log n)
- O(n log n)
- O(n)
- O(n^2)
The worst-case time complexity of the selection sort algorithm is O(n^2), where 'n' is the number of elements in the array. This is due to the nested loops used to find the minimum element in each iteration.
Loading...
Related Quiz
- In bubble sort, what happens in each pass through the array?
- 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?
- DFS can be used to detect _______ in a graph.
- An array is a _______ structure that stores a collection of _______ elements.
- The Floyd-Warshall algorithm computes the shortest paths between _______ pairs of vertices in a weighted graph.