TP4 dicho

This commit is contained in:
Geoffrey Frogeye 2015-02-24 10:41:45 +01:00
parent d56c275475
commit 0faf951d33

View file

@ -32,7 +32,20 @@ def seqTrie(l, a, b, x): # Jean-loup
return None
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