DEV Community

Lautaro Suarez
Lautaro Suarez

Posted on

1

Linear search algorithm

Lets see when can we use and what is the linear search algorithm for.

Lets say that we want to find an array a the index of an specific value we can do it with linear search when the array that we want to found is not something enormous, cause when the array is something gigantic we will want to use binary search but for now lets stay with linear search and lets see an example of it.

Image description

In the example above we can see that it will just return the index of the value given which in this case will be a, and the b value will be the array where we want to found the specific value.

If we also want to get the value of the specific index which should be the same as the given to the function we can just simple add a new variable to store the value and return it with the position value.

Hope someone found it interesting or helpful.

Lautaro

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay