Skip to content
Snippets Groups Projects
Commit c25f14b5 authored by Loic Scoth's avatar Loic Scoth
Browse files

dicho

parent e60ec8cf
Branches
No related tags found
No related merge requests found
......@@ -12,25 +12,22 @@ class node() :
def dicho(listKeys,key) :
t=len(listKeys)-1
d, f = 0, t
if (listKeys[f] == key) :
return (True,f)
elif (d < t and listKeys[d] == key) :
return (True, d)
while (f-d > 1) :
d, f = 0, t
while (f>= d) :
m=(d+f)//2
if (listKeys[m]>=key):
f=m
if ( f< t and listKeys[f] == key) :
return (True,f)
if (listKeys[m]==key) :
return m
if (listKeys[m]>key):
f=m - 1
#if ( f< t and listKeys[f] == key) :
# return True,f
else :
d=m
if (d < t and listKeys[d] == key) :
return (True, d)
d=m + 1
#if (d < t and listKeys[d] == key) :
# return True, d
return (False,0)
return -1
#def getSizeNode() :
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment