What is the complexity of selection sort algorithms?

20212021

What is the complexity of selection sort algorithms?

Answer: C. O(n²)For each position, Selection Sort scans the remaining unsorted portion to find the minimum element. Total comparisons: (n−1)+(n−2)+⋯+1=(n(n−1))/2 Thus, the…

  1. A.

    O(n)

  2. B.

    O(n log₂ n)

  3. C.

    O(n²)

  4. D.

    O(2n)

Attempted by 1317 students.

Show answer & explanation

Correct answer: C

For each position, Selection Sort scans the remaining unsorted portion to find the minimum element.

Total comparisons:

(n−1)+(n−2)+⋯+1=(n(n−1))/2

Thus, the complexity is quadratic.

Explore the full course: Rssb Basic Computer Instructor

Loading lesson…