What is the time complexity of searching for an element in an unsorted array of elements using linear search?

Answer and explanation

Correct answer: D.

  1. Step 1: In an unsorted array, the target element could be located at any index or absent entirely.
  2. Step 2: In the worst case, every element must be inspected sequentially, resulting in linear time complexity .
Answer
.
Why not the others: '' is constant time lookup by direct index; '' is binary search in a sorted array; '' represents nested loops.

Practise more Python Programming, Data Structures, Algorithms, Networks and Cybersecurity.

Free questions with an explanation for every one, and full timed Saudi Secondary School Certificate mock tests.

What is the time… | Saudi Secondary School Certificate