ajout images programme terminale + fichier python dichotomie recursive
This commit is contained in:
10
Recursivité/Diviser_pour_regner/dichotomie_recursive.py
Normal file
10
Recursivité/Diviser_pour_regner/dichotomie_recursive.py
Normal file
@@ -0,0 +1,10 @@
|
||||
def recherche(tab:list,x:int)-> bool:
|
||||
if len(tab) == 0:
|
||||
return False
|
||||
m = len(tab) // 2
|
||||
if tab[m] == x:
|
||||
return True
|
||||
elif tab [m] < x:
|
||||
return recherche(tab[m+1 :],x)
|
||||
else:
|
||||
return recherche(tab[:m],x)
|
||||
Reference in New Issue
Block a user