From c25f14b575da8d0d40a06c5746d0909d7f8bc9cf Mon Sep 17 00:00:00 2001
From: loic scoth <loic.scoth.etu@univ-lille.fr>
Date: Thu, 11 Jan 2024 12:46:51 +0100
Subject: [PATCH] dicho

---
 src/node.py | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/src/node.py b/src/node.py
index 48b9091..6c5e258 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() :
-- 
GitLab