Searching

AP Computer Science A· difficulty 2/5

// linear search on array of size n

What is the worst-case time complexity?

  • A

    O(n^2)

  • B

    O(log n)

  • C

    O(n)

    check_circle
  • D

    O(1)

Explanation

Linear search may inspect every element, giving O(n) worst case.

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

Related questions