Sorting

AP Computer Science A· difficulty 2/5

// selection sort on n elements

What is the time complexity?

  • A

    O(log n)

  • B

    O(n)

  • C

    O(n log n)

  • D

    O(n^2)

    check_circle

Explanation

Selection sort always makes ~n^2/2 comparisons regardless of input.

Want 10 more like this — adaptive to your weak spots?

Related questions