TP4 dicho
This commit is contained in:
parent
d56c275475
commit
0faf951d33
|
@ -32,7 +32,20 @@ def seqTrie(l, a, b, x): # Jean-loup
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def dicho(l, a, b, x): # Geoffrey
|
def dicho(l, a, b, x): # Geoffrey
|
||||||
return None
|
"""
|
||||||
|
list, int, int, a → (bool, int)
|
||||||
|
Renvoie la position d'un élément x dans la liste l
|
||||||
|
aux bornes a et b par dichotomie.
|
||||||
|
"""
|
||||||
|
a = d
|
||||||
|
f = b - 1
|
||||||
|
while d < f:
|
||||||
|
m = (d+f)//2
|
||||||
|
if l[m] < x:
|
||||||
|
d = m+1
|
||||||
|
else:
|
||||||
|
f = m
|
||||||
|
return x == l[d]
|
||||||
|
|
||||||
question(2) # Utiliser LEXIQUE
|
question(2) # Utiliser LEXIQUE
|
||||||
|
|
||||||
|
|
Reference in a new issue