首页
技术博客
登录
6mi
u
盘
搜
搜 索
技术博客
python-线性查找
python-线性查找
tech
2024-12-08
7
def
linear_search
(
L
,
e
)
:
found
=
False
for
i
in
range
(
len
(
L
)
)
:
# go through all elements
if
e
==
L
[
i
]
:
found
=
True
break
# with a break to stop loop while found, Complexity O(n)
return
found L
=
[
1
,
2
,
3
,
5
,
6
,
4
]
e
=
7
linear_search
(
L
,
e
)
转载请注明原文地址:https://tech.qufami.com/read-19533.html
最新回复
(
0
)