Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
projet_s6_loic.scoth.etu_mamadulamarana.bah.etu
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Loic Scoth
projet_s6_loic.scoth.etu_mamadulamarana.bah.etu
Commits
523b301c
Commit
523b301c
authored
1 year ago
by
Mamadu-lamarana Bah
Browse files
Options
Downloads
Patches
Plain Diff
search et debut insertion
parent
141276f7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/BTree.py
+8
-9
8 additions, 9 deletions
src/BTree.py
src/node.py
+32
-3
32 additions, 3 deletions
src/node.py
with
40 additions
and
12 deletions
src/BTree.py
+
8
−
9
View file @
523b301c
...
...
@@ -7,15 +7,10 @@ class Btree() :
self
.
root
=
root
self
.
k
=
k
def
search
(
self
,
value
,
node
=
self
.
root
):
(
found
,
index
)
=
node
.
search
(
value
)
if
(
found
):
return
(
node
,
index
)
elif
(
node
.
isLeaf
()
):
return
None
else
:
self
.
search
(
value
,
node
.
childs
[
index
])
def
search
(
self
,
value
):
return
self
.
root
.
search
(
value
)
# incomplet
def
insertion
(
self
,
value
):
if
(
self
.
root
==
None
):
self
.
root
=
Bnode
.
Node
(
self
.
k
)
...
...
@@ -24,6 +19,10 @@ class Btree() :
if
(
len
(
self
.
root
)
==
self
.
k
):
new_root
=
Bnode
.
Node
(
self
.
k
)
new_root
.
childs
[
0
]
=
self
.
root
if
(
self
)
else
:
self
.
root
.
insert_not_full
(
value
)
...
...
This diff is collapsed.
Click to expand it.
src/node.py
+
32
−
3
View file @
523b301c
...
...
@@ -2,9 +2,11 @@ from util import recherche_dichotomique
class
Node
()
:
def
__init__
(
self
,
nbKey
)
:
def
__init__
(
self
,
k
)
:
self
.
parent
=
self
.
keys
=
[]
self
.
childs
=
[]
self
.
k
=
k
def
isLeaf
():
return
(
len
(
self
.
childs
)
==
0
)
...
...
@@ -12,8 +14,35 @@ class Node() :
def
getSize
(
self
)
:
return
len
(
Keys
)
def
serach
(
self
,
k
):
return
recherche_dichotomique
(
k
,
self
.
keys
)
def
serach
(
self
,
value
):
(
found
,
index
)
=
recherche_dichotomique
(
value
,
self
.
keys
)
if
(
found
):
return
(
node
,
index
)
elif
(
node
.
isLeaf
()
):
return
None
else
:
self
.
childs
[
index
].
search
(
value
)
def
insert_not_full
(
self
,
value
):
(
found
,
index
)
=
self
.
search
(
value
)
if
(
self
.
isLeaf
())
:
if
(
not
found
):
self
.
keys
.
insert
()
=
value
else
:
if
(
len
(
self
.
childs
[
index
])
==
self
.
k
)
:
self
.
childs
[
index
].
splitNode
(
index
)
if
(
value
>
self
.
keys
[
index
])
:
index
+=
1
self
.
childs
[
index
].
insert_not_full
(
value
)
# j'ai pas encore bien compris comment m'y prendre
def
splitNode
(
self
)
:
parent
=
Node
(
self
.
k
)
m
=
self
.
keys
[(
len
(
self
.
node
.
keys
))
//
2
]
#def getSizeNode() :
#def getPos() :
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment