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

updt

parent 06d13f0f
No related branches found
No related tags found
No related merge requests found
#import Node as Bnode #import Node as Bnode
from node import * from Node import *
class Btree() : class Btree() :
......
...@@ -8,12 +8,12 @@ class Node() : ...@@ -8,12 +8,12 @@ class Node() :
self.k = k self.k = k
def isLeaf(self): def isLeaf(self):
""" # """
>>> Node([12, 42]).isLeaf() # >>> Node([12, 42]).isLeaf()
True # True
>>> Node([12, 42], [Node([1]), Node([25]), Node([50])]).isLeaf() # >>> Node([12, 42], [Node([1]), Node([25]), Node([50])]).isLeaf()
False # False
""" # """
return (len(self.childs) == 0) return (len(self.childs) == 0)
def getSize(self) : def getSize(self) :
...@@ -41,12 +41,17 @@ class Node() : ...@@ -41,12 +41,17 @@ class Node() :
def insert(self, value): def insert(self, value):
""" """
Exemple(s):
>>> Node([5]).insert(20)
(True, None, None, None)
>>> Node([5,15]).insert(12) >>> Node([5,15]).insert(12)
(False, 12, Node([5]), Node([15])) (False, 12, Node([5]), Node([15]))
>>> Node([5]).insert(20) >>> Node([12, 42], [Node([3]), Node([25]), Node([50])]).insert(52)
(True, None, None, None) (True, None, None, None)
>>> Node([12, 42], [Node([2, 3]), Node([25]), Node([50])]).insert(1) >>> Node([12, 42], [Node([2, 3]), Node([25]), Node([50])]).insert(1)
(True, None, None, None) (False, 12, Node([2]), Node([42]))
>>> Node([12, 42], [Node([2, 4], [Node([0, 1]), Node([3]), Node([7, 8])]), Node([25]), Node([50])]).insert(6)
(False, 12, Node([4]), Node([42]))
""" """
(found, index) = recherche_dichotomique(value, self.keys) (found, index) = recherche_dichotomique(value, self.keys)
if (not found) : if (not found) :
......
import unittest
if __name__ == "__main__":
unittest.main()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment