Skip to content
Snippets Groups Projects
Commit 4f604f1b authored by Mamadu-lamarana Bah's avatar Mamadu-lamarana Bah :speech_balloon:
Browse files

insertion dans Node et Btree et ajout de test

parent a33f2f27
No related branches found
No related tags found
No related merge requests found
......@@ -20,9 +20,16 @@ class Btree() :
return self.root.search(value)
def insertion(self, value):
"""
Exemple(s):
>>> Btree(2, Node([12, 42], [Node([2, 3]), Node([25]), Node([50])])).insertion(1)
True
"""
fini, milieu, g, d = self.root.insert(value)
if (not fini):
self.root = Node([milieu], [g, d])
new_root = Node([milieu], [g, d])
self.root = new_root
return self.root.childs[1].childs
......
......@@ -17,7 +17,7 @@ class Node() :
return (len(self.childs) == 0)
def getSize(self) :
return len(Keys)
return len(self.keys)
def search(self, value):
"""
......@@ -42,10 +42,10 @@ class Node() :
def insert(self, value):
"""
>>> Node([5,15]).insert(12)
(True, None, None, None)
(False, 12, Node([5]), Node([15]))
>>> Node([5]).insert(20)
(True, None, None, None)
>>> Node([12, 42], [Node([3,2])]).insert(1)
>>> Node([12, 42], [Node([2, 3]), Node([25]), Node([50])]).insert(1)
(True, None, None, None)
"""
(found, index) = recherche_dichotomique(value, self.keys)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment