首页 > 代码库 > Check time of different search methods

Check time of different search methods

https://github.com/Premiumlab/Python-for-Algorithms--Data-Structures--and-Interviews/blob/master/Mock%20Interviews/Ride%20Share%20Start-Up%20Company/Ride%20Share%20Company%20-%20Interview%20Questions%20-%20SOLUTIONS/Phone%20Screen%20-%20SOLUTION.ipynb

 

 

 

Phone Screen - SOLUTION

Problem

If you were given a list of n integers and knew that they were sorted, how quickly could you check if a given integer was in the list? Elaborate on your reasoning and search methods in general

Requirements

Try explaining your solution to someone and see if it makes sense ot them. Don‘t code anything for this problem

 

Solution

Hopefully this problem sounds familiar! We can use a binary search to search for an intger since the list is already sorted! This means we can find the item in O(logn) time and O(1) space!

Revisit the lectures on Binary Search and its implementation to fully get the reasoning behind this solution and problem!

Good Job!

Check time of different search methods