AlgoFrames

Trace a linear scan

Standard · Trace the algorithm · about 4 min

Follow linear search for 7 in [6, 2, 9, 2, 7, 5] and answer each question before the step plays.

Example 1

Input:

{"values":[6,2,9,2,7,5],"target":7}

Output:

4

Constraints

  • The trace uses the input shown.

Learn the idea first: Linear search, a visual lesson.

More Linear search problems