BinäreSuche
unknown
python
4 years ago
377 B
12
Indexable
def binaere_suche(elemente,wert):
links = 0
rechts = len(elemente)-1
while links <= rechts:
mitte = (links+rechts)//2
if elemente[mitte]==wert:
return elemente[mitte]
elif elemente[mitte]<wert:
links=mitte+1
elif elemente[mitte]>wert:
rechts=mitte-1
else:
return NoneEditor is loading...