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
072d024b
Commit
072d024b
authored
1 year ago
by
Mamadu-lamarana Bah
Browse files
Options
Downloads
Patches
Plain Diff
ajout de util.recherchedicho
parent
c25f14b5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/BTree.py
+8
-3
8 additions, 3 deletions
src/BTree.py
src/node.py
+16
-13
16 additions, 13 deletions
src/node.py
src/util.py
+60
-0
60 additions, 0 deletions
src/util.py
with
84 additions
and
16 deletions
src/BTree.py
+
8
−
3
View file @
072d024b
class
Btree
()
:
class
Btree
()
:
def
__init__
(
self
,
name
,
root
)
:
def
__init__
(
self
,
root
)
:
self
.
name
=
name
self
.
root
=
root
self
.
root
=
root
def
recherche
(
self
,
valeur
):
if
(
self
.
root
!=
None
)
:
index
=
0
while
index
#def search() :
#def search() :
#def insertion():
#def insertion():
...
...
This diff is collapsed.
Click to expand it.
src/node.py
+
16
−
13
View file @
072d024b
import
util
class
node
()
:
class
node
()
:
def
__init__
(
self
,
keys
,
child
,
kmin
,
kmax
)
:
def
__init__
(
self
,
k
,
kmin
,
kmax
)
:
self
.
keys
=
keys
self
.
keys
=
[]
self
.
child
=
child
self
.
childs
=
[]
self
.
kmin
=
kmin
self
.
kmin
=
kmin
self
.
kmax
=
kmax
self
.
kmax
=
kmax
#def search(key) :
def
search
(
self
,
Key
):
return
util
.
recherche_dichotomique
(
key
,
self
.
childs
)
def
getSize
(
self
)
:
return
len
(
Keys
)
def
addKey
(
self
)
:
def
dicho
(
listKeys
,
key
)
:
def
dicho
(
self
,
listKeys
,
key
)
:
t
=
len
(
listKeys
)
-
1
t
=
len
(
listKeys
)
-
1
d
,
f
=
0
,
t
d
,
f
=
0
,
t
while
(
f
>=
d
)
:
while
(
f
>=
d
)
:
...
@@ -33,10 +40,6 @@ class node() :
...
@@ -33,10 +40,6 @@ class node() :
#def getSizeNode() :
#def getSizeNode() :
#def getPos() :
#def getPos() :
#def setNewChild() :
#def setNewChild() :
#def removeChild() :
#def removeChild() :
def
getSize
(
listKey
)
:
return
len
(
listKey
)
#def isLeaf() :
#def isLeaf() :
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/util.py
0 → 100644
+
60
−
0
View file @
072d024b
import
doctest
def
compare
(
a
,
b
):
"""
:param a: (any) un élément
:param b: (any) un élément
:return: (bool) * 1 si a est plus grand que b
* 0 si a est égal à b
* -1 si a est plus petit que b
:CU: a et b sont comparables
:Exemples:
>>>
compare
(
1
,
2
)
-
1
>>>
compare
(
'
z
'
,
'
a
'
)
1
>>>
compare
(
0
,
0
)
0
"""
if
a
>
b
:
res
=
1
elif
a
<
b
:
res
=
-
1
else
:
res
=
0
return
res
def
recherche_dichotomique
(
x
,
l
,
cmp
=
compare
):
"""
:param x: (any) un élément
:param l: (list) une liste
:return: (bool) True si x appartient à l, False sinon
:CU: x doit être comparable aux éléments de l,
l est triée
:Exemples:
>>>
recherche_dichotomique
(
1
,
[])
(
False
,
-
1
)
>>>
l
=
list
(
range
(
10
))
>>>
recherche_dichotomique
(
5
,
l
)
(
True
,
5
)
>>>
recherche_dichotomique
(
5.5
,
l
)
(
False
,
-
1
)
"""
n
=
len
(
l
)
debut
,
fin
=
0
,
n
index
=
0
while
debut
<
fin
:
m
=
(
debut
+
fin
)
//
2
if
cmp
(
x
,
l
[
m
])
==
0
:
return
(
True
,
m
)
elif
cmp
(
x
,
l
[
m
])
>
0
:
index
+=
m
debut
=
m
+
1
else
:
fin
=
m
index
=
0
return
(
False
,
-
1
)
doctest
.
testmod
()
\ 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