DEV Community

Cover image for Search me if you can!! Linear & Binary search

Search me if you can!! Linear & Binary search

Phillip Shim on July 19, 2019

  What's your default method when you search for an item in an array? You could be familiar with the popular indexOf method or if you are versed i...
Collapse
 
jamesdengel profile image
James dengel • Edited

Also you can use better searching algorithms if you know what sort of distribution in the sorted array your data lies.
en.m.wikipedia.org/wiki/Exponentia...
en.m.wikipedia.org/wiki/Fibonacci_...

Useful in some situations embedded situations I'm looking at you :)

Collapse
 
shimphillip profile image
Phillip Shim

Cool! Never seen these search algorithms methods before :) thanks for sharing.

Collapse
 
andrewharpin profile image
Andrew Harpin • Edited

Good post for beginners!

Most searches outside of linear require the data to be sorted.

Which requires an efficient sorting algorithm, which could be a good follow up.

Collapse
 
jamesdengel profile image
James dengel

Efficient and appropriate is the best combination.
Not going to use radix sort for everything :)