We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bc0728f commit 42f02f1Copy full SHA for 42f02f1
2 files changed
bin_search.md
@@ -74,7 +74,7 @@ list.index()无法应对大规模数据的查询,需要用其它方法解决
74
75
- 模块接受排序后的列表。
76
- 本模块同样适用于长列表项。因为它就是用二分查找方法实现的,有兴趣可以看其源码(源码是一个很好的二分查找算法的例子,特别是很好地解决了边界条件极端的问题.)
77
-- 关于bisect模块的更多内容,可以参看官方文档
+- 关于bisect模块的更多内容,可以参看[官方文档](https://docs.python.org/2/library/bisect.html)
78
79
下面演示这个模块的一个函数
80
bin_search.py
@@ -74,13 +74,14 @@ def bsearch(l, value):
+-关于本模块,可以查看官方文档:https://docs.python.org/2/library/bisect.html
"""
#下面演示这个模块
81
from bisect import *
82
83
def bisectSearch(lst, x):
- i = bisect_left(lst, x)
84
+ i = bisect_left(lst, x) #bisect_left(lst,x)得到x在已经排序的lst中的位置
85
if i != len(lst) and lst[i] == x:
86
return i
87
0 commit comments