Algorithm Interview Topics, Vol. 2

Search Algorithms in Python, Explained

How to Design An Efficient Search Algorithm

Paul Torres
Analytics Vidhya
Published in
6 min readApr 11, 2021

--

Photo by Marten Newhall on Unsplash

We’ve all done exercises before where we’ve had to see if a string contained a character or returned a Boolean after trying to find a numeric value. The keywords are all there: in, contains, if x == value.

But how many of us just starting out truly understand what is going on behind the scenes and what mechanics determine what is the best algorithm to use.

This article aims to go over the differences in algorithms like sequential search, binary search, and hashing to better understand what is going on and what to use in certain situations. We’ll also have common interview questions that may come up when pursuing a job in programming.

Sequential Search

A sequential search occurs when you sequentially go through a data structure, comparing the value found with your condition. If the value does not fulfill your condition then you continue on to the next value.

This method of searching is split into two different categories — whether the data structure you are searching is ordered or unordered.

--

--

Paul Torres
Analytics Vidhya

Data Scientist with a Physicist’s heart. Looking through numbers to tell a story that people will care about.