16 lines
379 B
Python
16 lines
379 B
Python
def chercher(tab, x, i, j):
|
|
'''Renvoie l'indice de x dans tab, si x est dans tab,
|
|
None sinon.
|
|
On suppose que tab est trié dans l'ordre croissant.'''
|
|
if i > j:
|
|
return None
|
|
m = (i + j) // ...
|
|
if ... < x:
|
|
return chercher(tab, x, ... , ...)
|
|
elif tab[m] > x:
|
|
return chercher(tab, x, ... , ...)
|
|
else:
|
|
return ...
|
|
|
|
|