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
07d033a6
Commit
07d033a6
authored
1 year ago
by
Mamadu-lamarana Bah
Browse files
Options
Downloads
Patches
Plain Diff
linearisation
parent
875274ad
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/BTree.py
+20
-18
20 additions, 18 deletions
src/BTree.py
src/Node.py
+46
-13
46 additions, 13 deletions
src/Node.py
src/NodeTest.py
+0
-7
0 additions, 7 deletions
src/NodeTest.py
src/test/BtreeTest.py
+0
-0
0 additions, 0 deletions
src/test/BtreeTest.py
src/test/NodeTest.py
+14
-0
14 additions, 0 deletions
src/test/NodeTest.py
with
80 additions
and
38 deletions
src/BTree.py
+
20
−
18
View file @
07d033a6
...
...
@@ -41,26 +41,28 @@ class Btree() :
new_root
=
Node
([
milieu
],
[
g
,
d
])
self
.
root
=
new_root
return
True
def
linearisation
(
self
,
node
):
"""
Exemple(s):
>>>
a
=
Btree
(
2
)
>>>
node
=
Node
([
6
],
[
Node
([
1
]),
Node
([
7
])])
>>>
a
.
linearisation
(
node
)
()
"""
if
(
node
):
if
(
node
.
isLeaf
()):
for
i
in
node
.
keys
:
print
(
i
)
else
:
if
(
len
(
node
.
keys
)
==
1
):
self
.
linearisation
(
node
.
childs
[
0
])
print
(
node
.
keys
[
0
])
self
.
linearisation
(
node
.
childs
[
1
])
else
:
for
#def search() :
#def insertion():
#def createNode() :
#def delete() :
#def linear() :
#def createTree() :
#def height() :
#def isArbre() :
#def getNbKeys () :
#def getSize () :
#def changeRoot() :
#def isEqual() :
def
__repr__
(
self
)
:
return
f
"
Btree(
{
self
.
root
}
)
"
...
...
This diff is collapsed.
Click to expand it.
src/Node.py
+
46
−
13
View file @
07d033a6
...
...
@@ -8,12 +8,12 @@ class Node() :
self
.
k
=
k
def
isLeaf
(
self
):
#
"""
#
>>> Node([12, 42]).isLeaf()
#
True
#
>>> Node([12, 42], [Node([1]), Node([25]), Node([50])]).isLeaf()
#
False
#
"""
"""
>>>
Node
([
12
,
42
]).
isLeaf
()
True
>>>
Node
([
12
,
42
],
[
Node
([
1
]),
Node
([
25
]),
Node
([
50
])]).
isLeaf
()
False
"""
return
(
len
(
self
.
childs
)
==
0
)
def
getSize
(
self
)
:
...
...
@@ -42,19 +42,33 @@ class Node() :
def
insert
(
self
,
value
):
"""
Exemple(s):
>>>
Node
([
5
]).
insert
(
20
)
>>>
node
=
Node
([
5
])
>>>
node
.
insert
(
20
)
(
True
,
None
,
None
,
None
)
>>>
node
.
search
(
20
)
(
Node
([
5
,
20
]),
1
)
>>>
Node
([
5
,
15
]).
insert
(
12
)
(
False
,
12
,
Node
([
5
]),
Node
([
15
]))
>>>
a
=
Node
([
12
,
42
],
[
Node
([
3
]),
Node
([
25
]),
Node
([
50
])])
>>>
a
.
insert
(
52
)
>>>
node
.
search
(
12
)
>>>
node
=
Node
([
12
,
42
],
[
Node
([
3
]),
Node
([
25
]),
Node
([
50
])])
>>>
node
.
insert
(
52
)
(
True
,
None
,
None
,
None
)
>>>
a
.
search
(
52
)
>>>
node
.
search
(
52
)
(
Node
([
50
,
52
]),
1
)
>>>
Node
([
12
,
42
],
[
Node
([
2
,
3
]),
Node
([
25
]),
Node
([
50
])]).
insert
(
1
)
>>>
node
=
Node
([
12
,
42
],
[
Node
([
2
,
3
]),
Node
([
25
]),
Node
([
50
])])
>>>
node
.
insert
(
1
)
(
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
)
>>>
node
.
search
(
1
)
(
Node
([
1
]),
0
)
>>>
node
=
Node
([
12
,
42
],
[
Node
([
2
,
4
],
[
Node
([
0
,
1
]),
Node
([
3
]),
Node
([
7
,
8
])]),
Node
([
25
]),
Node
([
50
])])
>>>
node
.
insert
(
6
)
(
False
,
12
,
Node
([
4
]),
Node
([
42
]))
>>>
node
=
Node
([
12
,
42
],
[
Node
([
2
,
3
,
4
]),
Node
([
25
]),
Node
([
50
])],
3
)
>>>
node
.
insert
(
1
)
(
True
,
None
,
None
,
None
)
"""
(
found
,
index
)
=
recherche_dichotomique
(
value
,
self
.
keys
)
if
(
not
found
)
:
...
...
@@ -73,6 +87,8 @@ class Node() :
if
(
len
(
self
.
keys
)
>
self
.
k
)
:
milieu
,
g
,
d
=
self
.
splitNode
()
return
False
,
milieu
,
g
,
d
else
:
return
True
,
None
,
None
,
None
else
:
return
True
,
None
,
None
,
None
else
:
...
...
@@ -106,10 +122,27 @@ class Node() :
return
(
self
.
keys
[
milieu
],
g
,
d
)
def
linearisation
(
self
):
"""
Exemple(s):
>>>
Node
([
12
,
42
],
[
Node
([
2
,
3
]),
Node
([
25
]),
Node
([
50
])]).
linearisation
()
[
2
,
3
,
12
,
25
,
42
,
50
]
"""
if
(
self
.
isLeaf
()):
res
=
self
.
keys
else
:
res
=
[]
for
i
in
range
(
0
,
len
(
self
.
keys
)):
res
.
extend
(
self
.
childs
[
i
].
linearisation
())
res
.
append
(
self
.
keys
[
i
])
res
.
extend
(
self
.
childs
[
len
(
self
.
childs
)
-
1
].
linearisation
())
return
res
def
__repr__
(
self
)
:
return
f
"
Node(
{
self
.
keys
}
)
"
if
__name__
==
'
__main__
'
:
import
doctest
doctest
.
testmod
(
verbose
=
False
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/NodeTest.py
deleted
100644 → 0
+
0
−
7
View file @
875274ad
import
unittest
if
__name__
==
"
__main__
"
:
unittest
.
main
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/BtreeTest.py
→
src/
test/
BtreeTest.py
+
0
−
0
View file @
07d033a6
File moved
This diff is collapsed.
Click to expand it.
src/test/NodeTest.py
0 → 100644
+
14
−
0
View file @
07d033a6
import
unittest
class
NodeTest
:
def
setUp
(
self
):
self
.
node
=
Node
([
12
,
42
],
)
if
__name__
==
"
__main__
"
:
import
sys
sys
.
path
.
insert
(
1
,
'
./src
'
)
sys
.
path
.
insert
(
2
,
'
../src
'
)
from
Node
import
*
unittest
.
main
()
\ No newline at end of file
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