19 lines
412 B
Python
19 lines
412 B
Python
|
|
def dichotomie(tab, x):
|
||
|
|
"""applique une recherche dichotomique pour déterminer
|
||
|
|
si x est dans le tableau trié tab.
|
||
|
|
La fonction renvoie True si tab contient x et False sinon"""
|
||
|
|
|
||
|
|
debut = 0
|
||
|
|
fin = ...
|
||
|
|
while debut <= fin:
|
||
|
|
m = ...
|
||
|
|
if x == tab[m]:
|
||
|
|
return ...
|
||
|
|
if x > tab[m]:
|
||
|
|
debut = ...
|
||
|
|
else:
|
||
|
|
fin = ...
|
||
|
|
return False
|
||
|
|
|
||
|
|
|