Area of Improvements

Review your assessments and practice — drill into each subject, then each attempt, then each question.

Back to summary
C Programming · Round 1

Question 2 of 10

Topic: OperatorsDifficulty: HardBloom: Analyze
Question

What is the time complexity of a linear search over an array, and why?

Result
Knowledge
55%
Delivery
82%
Technical relevancy
60%
Technical term match
50%
Your recording
Your transcript

Um, linear search is O(n) because you go through the array one by one. Worst case you check everything. I don't really remember the best case though.

Better answer

Linear search inspects each element until it finds the target or exhausts the array, so worst-case and average-case complexity is O(n) and best-case (target at index 0) is O(1). Space is O(1). It's the right choice on unsorted data or very small arrays where cache locality dominates.

Coverage
Hit 2 of 4
  • States worst-case O(n)
  • Mentions best-case O(1)
  • Notes O(1) auxiliary space
  • Justifies why each element must be checked
Gaps
  • Did not state best-case complexity
Misconceptions
  • Confused average-case with worst-case