diff --git a/README.md b/README.md index 7d304b3a2c505090fb852ec20bf337017d351814..a3b08ed14c202b5c1144d434a8b941283323b699 100644 --- a/README.md +++ b/README.md @@ -2,22 +2,39 @@ ## authors -Mamadou Lamarana Bah +Mamadu Lamarana Bah Loïc Scoth -## TODO +## Problèmes et erreurs + +Le projet contient quelques problèmes: +La suppression n'est pas terminé, celle-ci gère certains cas feuille mais ne fonctionne pas correctement. +expérimentation suppr1: niveau 2 de l'arbre, il y a un noeud vide due au rééquilibrage après une fusion  + +les cas racine et noeud interne ne sont pas pris en compte. -ajout commande execution/tests -Ce qui ne vas pas ## Description du projet Le projet consiste à la création et à la représentation d'un arbre binaire, constitué de noeud et de feuilles, que nous créons. Celui-ci est modulable, nous pouvons ajouter ou supprimer des noeuds mais également rechercher l'emplacement d'un noeud dans cet arbre. +## commande + +Expérimentation : +projet-s-6-loic-scoth-etu-mamadulamarana-bah-etu/src$ python3 experimentation.py + +Test: +projet-s-6-loic-scoth-etu-mamadulamarana-bah-etu/src$ python3 BTree.py + +projet-s-6-loic-scoth-etu-mamadulamarana-bah-etu/src$ python3 Node.py + +projet-s-6-loic-scoth-etu-mamadulamarana-bah-etu/src$ python3 util.py + + ## Status -En cours, Suppression à terminer +Terminé, suppression non fini ## UML @@ -25,6 +42,38 @@ Voici un UML simple de notre projet :  +## Compléxité + +### util + +recheche dicho : O(log(n)) + +### Node + +search: O(log(n)) si arbre équilibré, en O(n) dans le pire des cas (arbre déséquilibré, parcours donc tout les noeuds) + +is_ArbreB: O(n) + +insert: O(log(n)) dans le meilleur des cas, O(h) dans le pire des cas ,h correspond à la hauteur de l'arbre + +suppression: O(log(n)) dans le meilleur de cas, O(h + n) dans le pire des cas + +splitNode: O(n) + +linearisation: O(n) + +### Btree + +search: voir Node + +insertion: voir Node + +linearisation: voir Node + +isBalance: voir Node + +suppr: voir Node (non terminé) + ### Semaine 1 Mise en place du projet, compréhension du sujet et création des premières classes. @@ -77,4 +126,12 @@ Suite suppression. ### semaine 13 -suite suppression \ No newline at end of file +suite suppression. + +### semaine 14 + +suite suppression et expérimentation. + +### semaine 15 + +Dernières modifs et soutenance. \ No newline at end of file diff --git a/src/ArbreB/Graph.gv b/src/ArbreB/Graph.gv index fbd621aac8807411d3cc3fa04dcd693958127938..a6dc586c47baf840b5f9cf1aff8733073f64703d 100644 --- a/src/ArbreB/Graph.gv +++ b/src/ArbreB/Graph.gv @@ -33,12 +33,15 @@ graph { "[22, 30]" "[14]" -- "[22, 30]" "[22, 30]" - "[]" - "[22, 30]" -- "[]" - "[]" - "[16, 18]" - "[]" -- "[16, 18]" - "[16, 18]" + "[18]" + "[22, 30]" -- "[18]" + "[18]" + "[16]" + "[18]" -- "[16]" + "[16]" + "[20]" + "[18]" -- "[20]" + "[20]" "[26]" "[22, 30]" -- "[26]" "[26]" diff --git a/src/ArbreB/Graph.gv.jpg b/src/ArbreB/Graph.gv.jpg index 01fce48d9be8158ad91e1058c1f45250a1496e37..820cb6a0f225e9920aa9e8cd467e450b32131b11 100644 Binary files a/src/ArbreB/Graph.gv.jpg and b/src/ArbreB/Graph.gv.jpg differ diff --git a/src/ArbreB/Graph.gv.pdf b/src/ArbreB/Graph.gv.pdf deleted file mode 100644 index c30e111e89c95f09e322d43d73319fce6e08f297..0000000000000000000000000000000000000000 Binary files a/src/ArbreB/Graph.gv.pdf and /dev/null differ diff --git a/src/ArbreB/GraphPb.gv.jpg b/src/ArbreB/GraphPb.gv.jpg new file mode 100644 index 0000000000000000000000000000000000000000..01fce48d9be8158ad91e1058c1f45250a1496e37 Binary files /dev/null and b/src/ArbreB/GraphPb.gv.jpg differ diff --git a/src/BTree.py b/src/BTree.py index e7dd336438327ba442855fdb5d7bd912a0c2b7e3..17e1f7721ccca0b1c20c87e15d117a4b8c8e03ad 100644 --- a/src/BTree.py +++ b/src/BTree.py @@ -104,13 +104,14 @@ class Btree() : def suppr(self, value, k): """ + Non fonctionnel + Supprimer une valeur dans l'arbre Params : value : (int), valeur à supprimer k : (int), nombre de clés Return : - #TODO Exemple(s): >>> arbreB = Btree(2, Node([5,25])) >>> arbreB.suppr(25,2) @@ -129,4 +130,4 @@ class Btree() : if __name__ == '__main__': import doctest - doctest.testmod(verbose=False) \ No newline at end of file + doctest.testmod(verbose=True) \ No newline at end of file diff --git a/src/Node.py b/src/Node.py index a95f5c278c9b6cf72df2b0ffa7878372ff384bf5..526ff576cd72e3e1eee3a9e2a3b4f84cb9b23e50 100644 --- a/src/Node.py +++ b/src/Node.py @@ -20,8 +20,6 @@ class Node() : """ return (len(self.childs) == 0) - def getSize(self) : - return len(self.keys) def search(self, value): """ @@ -299,4 +297,4 @@ class Node() : if __name__ == '__main__': import doctest - doctest.testmod(verbose=False) \ No newline at end of file + doctest.testmod(verbose=True) \ No newline at end of file diff --git a/src/Visualization.py b/src/Visualization.py index abf5077f2c2ab5ba0451cfb5f7e7f0aa1035a3d9..6af0e932f07a145091f84fde2f16b6a9139d35cf 100644 --- a/src/Visualization.py +++ b/src/Visualization.py @@ -11,7 +11,6 @@ class Visualization() : self.add_node_to_graph(self.btree.root) def add_node_to_graph(self, node): -# print(repr(node.keys)) nodeKeys = repr(node.keys) self.g.node(nodeKeys) for child in node.childs: diff --git a/src/__pycache__/BTree.cpython-310.pyc b/src/__pycache__/BTree.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c695200698328855488e1cbd0c9b5b8a5ccb7a43 Binary files /dev/null and b/src/__pycache__/BTree.cpython-310.pyc differ diff --git a/src/__pycache__/Node.cpython-310.pyc b/src/__pycache__/Node.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..64a9c015d562e1a63d4fce2d59eb9578e7eda869 Binary files /dev/null and b/src/__pycache__/Node.cpython-310.pyc differ diff --git a/src/__pycache__/Visualization.cpython-310.pyc b/src/__pycache__/Visualization.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8ae2980c4d458fb557a177fed777273c55632244 Binary files /dev/null and b/src/__pycache__/Visualization.cpython-310.pyc differ diff --git a/src/__pycache__/util.cpython-310.pyc b/src/__pycache__/util.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d4e4ed896c375ec63a319e5e0ee25842b4ffa895 Binary files /dev/null and b/src/__pycache__/util.cpython-310.pyc differ diff --git a/src/experimentation.py b/src/experimentation.py index c5998c2c4134d6636dfbc39d78fe1b22511e5eab..2712f5d6da56b9380cb4d37f2706358401ea2279 100644 --- a/src/experimentation.py +++ b/src/experimentation.py @@ -30,12 +30,11 @@ class experimentation: print("Non fonctionnel") for n in [2, 4, 5] + list(range(6, 37, 2)) + [7, 9, 11, 13]: self.btree.insertion(n) - - + self.btree.suppr(20,2) - Visualization(self.btree).render() #for n in [14,10,20,18,16,24,6] + Visualization(self.btree).render() print(self.btree) diff --git a/src/util.py b/src/util.py index bf1d1d4b6fb9e2b37b8ae02feef2eebef5715519..8e569eae353d851f5886e18e798987a6dbdf889f 100644 --- a/src/util.py +++ b/src/util.py @@ -33,6 +33,9 @@ def recherche_dichotomique(x, l, cmp = compare): Cet indice `index` indiquera soit la place de l'élément x dans la liste, soit la place du fils susceptible de contenir l'élément x recherché dans un arbre de recherche. + + complexité: + log(n) Précondition : `liste` est triée par ordre croissant Exemple(s) :