Data Structure Time Complexity Question #15245
MCQ Single Best Answer Easy

QWhat is the time complexity of a linear search algorithm for an unsorted array of n elements in the worst case?

ID: #15245 Time Complexity 160 views
Question Info
#15245Q ID
EasyDifficulty
Time ComplexityTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A O(1)
  • B O(log n)
  • C O(n)
  • D O(n^2)
Correct Answer: Option C

Explanation

In a linear search algorithm, each element of the array is checked one by one until the target element is found or the end of the array is reached. In the worst case, where the target element is at the last position or absent from the array, the algorithm will need to examine all n elements. Therefore, the time complexity of a linear search is linear, denoted as O(n).

Share This Question

Challenge a friend or share with your study group.