码迷,mamicode.com
首页 > 其他好文 > 详细

Check time of different search methods

时间:2017-06-08 11:01:51      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:htm   this   log   any   require   div   ini   http   screen   

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

标签:htm   this   log   any   require   div   ini   http   screen   

原文地址:http://www.cnblogs.com/prmlab/p/6961060.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!