diff --git a/src/node.py b/src/node.py index 48b9091b6dc02a3e2174c54bf0f63165860bc4a3..6c5e258925e6c7a6eb9d181316b62d7ba0b15564 100644 --- a/src/node.py +++ b/src/node.py @@ -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() :