Linear Search

What is Linear Search?

Linear search is a search algorithm that searches for a target value in a collection of elements by iterating through each element in the collection until the target value is found or the end of the collection is reached.

How to implement Linear Search?

To implement linear search, we need to iterate through each element in the collection until the target value is found or the end of the collection is reached.

Example

Let's search for the target value 3 in the collection [1, 2, 3, 4, 5] using linear search.

First, we need to iterate through each element in the collection until the target value is found or the end of the collection is reached.

ElementTarget ValueIs Found
13No
23No
33Yes

The target value 3 is found in the collection [1, 2, 3, 4, 5].

Heart with ribbonBecome a SponsorHeart with ribbon

Become a sponsor and help us maintain and improve this project. Every contribution counts. Thank you!