Check time of different search methods

Posted Premiumlab

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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的主要内容,如果未能解决你的问题,请参考以下文章

influxdb sum first value metric of different series but the same time interval for grafana graph

539. Minimum Time Difference 最小时差

[Lintcode]142. O Check Power of 2

[LintCode] O Check Power of 2

zabbix安装成功后,访问页面,在check of pre-requisites通不过,不知道如何去修改以让其进入下一步?

Failed to check the status of the service报错解决