Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AP-KINADINOVA-Dariya
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
Dariya Kinadinova
AP-KINADINOVA-Dariya
Commits
60556cd7
Commit
60556cd7
authored
1 year ago
by
Kinadinova Dariya
Browse files
Options
Downloads
Patches
Plain Diff
tri_sort
parent
c05172cb
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
tp7/analyse_tris.csv
+97
-97
97 additions, 97 deletions
tp7/analyse_tris.csv
tp7/analyse_tris2.py
+2
-4
2 additions, 4 deletions
tp7/analyse_tris2.py
tp7/tp_tris.py
+22
-27
22 additions, 27 deletions
tp7/tp_tris.py
tp7/tris_nbcomp.png
+0
-0
0 additions, 0 deletions
tp7/tris_nbcomp.png
with
121 additions
and
128 deletions
tp7/analyse_tris.csv
+
97
−
97
View file @
60556cd7
...
@@ -2,101 +2,101 @@ taille;"tri séléction";"tri insertion"
...
@@ -2,101 +2,101 @@ taille;"tri séléction";"tri insertion"
0; 0.00; 0.00
0; 0.00; 0.00
1; 0.00; 0.00
1; 0.00; 0.00
2; 1.00; 1.00
2; 1.00; 1.00
3; 3.00; 2.
54
3; 3.00; 2.
66
4; 6.00; 4.
9
4
4; 6.00; 4.
8
4
5; 10.00;
7.74
5; 10.00;
8.02
6; 15.00; 10.
9
4
6; 15.00; 10.4
6
7; 21.00; 15.
12
7; 21.00; 15.
74
8; 28.00; 1
8
.3
2
8; 28.00; 1
9
.3
0
9; 36.00; 2
4
.4
6
9; 36.00; 2
5
.4
4
10; 45.00; 28.
7
4
10; 45.00; 28.
4
4
11; 55.00; 3
6.26
11; 55.00; 3
4.82
12; 66.00; 42.
6
0
12; 66.00; 42.0
2
13; 78.00; 4
7.62
13; 78.00; 4
8.54
14; 91.00; 55.
40
14; 91.00; 55.
16
15; 105.00; 6
4.76
15; 105.00; 6
6.28
16; 120.00; 7
5.7
2
16; 120.00; 7
3.1
2
17; 136.00;
81.50
17; 136.00;
79.96
18; 153.00; 9
3.78
18; 153.00; 9
2.14
19; 171.00; 99.
70
19; 171.00; 99.
98
20; 190.00; 1
08.00
20; 190.00; 1
12.58
21; 210.00; 12
1.72
21; 210.00; 12
2.30
22; 231.00; 136.
7
0
22; 231.00; 136.
2
0
23; 253.00; 14
8.3
2
23; 253.00; 14
9.0
2
24; 276.00; 15
4.62
24; 276.00; 15
9.28
25; 300.00; 17
7.60
25; 300.00; 17
1.26
26; 325.00; 18
5
.9
8
26; 325.00; 18
8
.9
0
27; 351.00; 19
5.04
27; 351.00; 19
6.46
28; 378.00; 21
4.66
28; 378.00; 21
3.12
29; 406.00; 22
8.92
29; 406.00; 22
4.26
30; 435.00; 24
3.02
30; 435.00; 24
5.64
31; 465.00; 2
63.00
31; 465.00; 2
59.88
32; 496.00; 27
8
.32
32; 496.00; 27
9
.32
33; 528.00;
300.08
33; 528.00;
290.44
34; 561.00; 31
3.08
34; 561.00; 31
7.86
35; 595.00; 33
2.32
35; 595.00; 33
3.44
36; 630.00; 3
47.46
36; 630.00; 3
36.84
37; 666.00; 3
6
3.
5
6
37; 666.00; 3
7
3.
8
6
38; 703.00; 3
85.3
8
38; 703.00; 3
90.1
8
39; 741.00; 4
02.2
6
39; 741.00; 4
11.0
6
40; 780.00; 4
31.92
40; 780.00; 4
22.26
41; 820.00; 4
49.30
41; 820.00; 4
37.46
42; 861.00; 4
68.2
6
42; 861.00; 4
72.1
6
43; 903.00; 48
2.66
43; 903.00; 48
6.10
44; 946.00; 5
14.60
44; 946.00; 5
06.98
45; 990.00; 5
47.12
45; 990.00; 5
32.68
46; 1035.00; 558.56
46; 1035.00; 558.56
47; 1081.00; 5
91.6
8
47; 1081.00; 5
87.1
8
48; 1128.00;
596.86
48; 1128.00;
606.10
49; 1176.00; 63
8.16
49; 1176.00; 63
1.00
50; 1225.00; 66
2.70
50; 1225.00; 66
9.22
51; 1275.00; 68
2.6
2
51; 1275.00; 68
7.8
2
52; 1326.00; 7
07.1
0
52; 1326.00; 7
16.2
0
53; 1378.00; 7
54.44
53; 1378.00; 7
44.82
54; 1431.00; 7
58.7
6
54; 1431.00; 7
79.6
6
55; 1485.00;
804.98
55; 1485.00;
784.60
56; 1540.00; 81
5.14
56; 1540.00; 81
7.60
57; 1596.00; 8
56.56
57; 1596.00; 8
41.68
58; 1653.00; 8
57.58
58; 1653.00; 8
84.94
59; 1711.00; 91
4.12
59; 1711.00; 91
1.00
60; 1770.00; 9
21.60
60; 1770.00; 9
52.36
61; 1830.00; 9
83.40
61; 1830.00; 9
69.26
62; 1891.00;
987.16
62; 1891.00;
1016.92
63; 1953.00; 103
7.34
63; 1953.00; 103
3.92
64; 2016.00; 10
86.56
64; 2016.00; 10
61.48
65; 2080.00; 108
4.88
65; 2080.00; 108
2.60
66; 2145.00; 11
5
8.
24
66; 2145.00; 11
4
8.
86
67; 2211.00; 11
72.10
67; 2211.00; 11
51.72
68; 2278.00; 118
5.94
68; 2278.00; 118
9.32
69; 2346.00; 12
20.80
69; 2346.00; 12
47.46
70; 2415.00; 12
92.92
70; 2415.00; 12
49.00
71; 2485.00; 13
08.74
71; 2485.00; 13
12.82
72; 2556.00; 13
4
3.22
72; 2556.00; 133
8
.22
73; 2628.00; 13
90.08
73; 2628.00; 13
82.14
74; 2701.00; 14
28.4
8
74; 2701.00; 14
16.9
8
75; 2775.00; 14
45.40
75; 2775.00; 14
63.36
76; 2850.00; 1
475.92
76; 2850.00; 1
515.78
77; 2926.00; 15
34.3
4
77; 2926.00; 15
52.4
4
78; 3003.00; 1
604.52
78; 3003.00; 1
592.64
79; 3081.00; 16
10.94
79; 3081.00; 16
26.36
80; 3160.00; 16
74
.74
80; 3160.00; 16
55
.74
81; 3240.00; 16
93.34
81; 3240.00; 16
72.96
82; 3321.00; 17
29.02
82; 3321.00; 17
40.14
83; 3403.00; 17
99.78
83; 3403.00; 17
61.00
84; 3486.00; 180
0.70
84; 3486.00; 180
6.66
85; 3570.00; 18
84
.1
0
85; 3570.00; 18
70
.1
2
86; 3655.00; 19
54.98
86; 3655.00; 19
06.36
87; 3741.00; 19
64.98
87; 3741.00; 19
50.14
88; 3828.00; 201
2.42
88; 3828.00; 201
1.50
89; 3916.00; 20
11.72
89; 3916.00; 20
83.56
90; 4005.00; 208
0.66
90; 4005.00; 208
5.50
91; 4095.00; 21
47
.1
8
91; 4095.00; 21
59
.1
0
92; 4186.00; 21
61.90
92; 4186.00; 21
86.72
93; 4278.00; 22
16.44
93; 4278.00; 22
20.78
94; 4371.00; 22
90.34
94; 4371.00; 22
87.80
95; 4465.00; 23
47.2
6
95; 4465.00; 23
03.5
6
96; 4560.00; 23
89.5
4
96; 4560.00; 23
57.1
4
97; 4656.00; 24
13.08
97; 4656.00; 24
34.12
98; 4753.00; 24
83.92
98; 4753.00; 24
58.50
99; 4851.00; 25
23.12
99; 4851.00; 25
48.74
100; 4950.00; 2
608.62
100; 4950.00; 2
597.96
This diff is collapsed.
Click to expand it.
tp7/analyse_tris2.py
+
2
−
4
View file @
60556cd7
...
@@ -41,7 +41,7 @@ def analyser_tri(tri: Callable[[list[T], Callable[[T, T], int]], NoneType],
...
@@ -41,7 +41,7 @@ def analyser_tri(tri: Callable[[list[T], Callable[[T, T], int]], NoneType],
res
+=
compare
.
counter
res
+=
compare
.
counter
return
res
/
nbre_essais
return
res
/
nbre_essais
def
tri_
comp
(
l
:
list
[
T
],
comp
:
Callable
[[
T
,
T
],
int
]
=
compare
):
def
tri_
sort
(
l
:
list
[
T
],
comp
:
Callable
[[
T
,
T
],
int
]
=
compare
):
"""
à_remplacer_par_ce_que_fait_la_fonction
"""
à_remplacer_par_ce_que_fait_la_fonction
Précondition :
Précondition :
...
@@ -61,15 +61,13 @@ if (__name__ == '__main__'):
...
@@ -61,15 +61,13 @@ if (__name__ == '__main__'):
TAILLE_MAX
=
100
TAILLE_MAX
=
100
c_select
=
[
0.0
]
*
(
TAILLE_MAX
+
1
)
c_select
=
[
0.0
]
*
(
TAILLE_MAX
+
1
)
c_insert
=
[
0.0
]
*
(
TAILLE_MAX
+
1
)
c_insert
=
[
0.0
]
*
(
TAILLE_MAX
+
1
)
# creating c_sort
c_sort
=
[
0.0
]
*
(
TAILLE_MAX
+
1
)
c_sort
=
[
0.0
]
*
(
TAILLE_MAX
+
1
)
for
t
in
range
(
TAILLE_MAX
+
1
):
for
t
in
range
(
TAILLE_MAX
+
1
):
c_select
[
t
]
=
analyser_tri
(
tri_select
,
1
,
t
)
c_select
[
t
]
=
analyser_tri
(
tri_select
,
1
,
t
)
# inutile de moyenner pour le tri par sélection
# inutile de moyenner pour le tri par sélection
c_insert
[
t
]
=
analyser_tri
(
tri_insert
,
NB_ESSAIS
,
t
)
c_insert
[
t
]
=
analyser_tri
(
tri_insert
,
NB_ESSAIS
,
t
)
# for sorting
c_sort
[
t
]
=
analyser_tri
(
tri_sort
,
NB_ESSAIS
,
t
)
c_sort
[
t
]
=
analyser_tri
(
tri_comp
,
NB_ESSAIS
,
t
)
# Sauvegarde des données calculées dans un fichier au format CSV
# Sauvegarde des données calculées dans un fichier au format CSV
prem_ligne
=
'
taille;
"
tri séléction
"
;
"
tri insertion
"
\n
'
prem_ligne
=
'
taille;
"
tri séléction
"
;
"
tri insertion
"
\n
'
...
...
This diff is collapsed.
Click to expand it.
tp7/tp_tris.py
+
22
−
27
View file @
60556cd7
...
@@ -4,6 +4,10 @@ import matplotlib.pyplot as plt
...
@@ -4,6 +4,10 @@ import matplotlib.pyplot as plt
from
analyse_tris
import
tri_select
from
analyse_tris
import
tri_select
from
math
import
sqrt
from
math
import
sqrt
from
analyse_tris
import
analyser_tri
from
analyse_tris
import
analyser_tri
from
typing
import
Callable
from
compare
import
compare
from
ap_decorators
import
count
from
tris
import
*
# Préliminaires
# Préliminaires
...
@@ -20,29 +24,25 @@ def liste_alea(n: int) -> list[int]:
...
@@ -20,29 +24,25 @@ def liste_alea(n: int) -> list[int]:
return
l
return
l
# Évaluation expérimentale de la complexité en temps
# Évaluation expérimentale de la complexité en temps
TAILLE_MAX
=
100
compare
=
count
(
compare
)
L
=
[]
T
=
[]
for
t
in
range
(
1
,
TAILLE_MAX
+
1
):
def
analyser_tri
(
tri
:
Callable
[[
list
[
T
],
Callable
[[
T
,
T
],
int
]],
NoneType
],
rlist
=
liste_alea
(
t
)
nbre_essais
:
int
,
time
=
timeit
.
timeit
(
stmt
=
'
tri_select(l)
'
,
setup
=
'
from __main__ import tri_select, l
'
,
globals
=
{
'
l
'
:
rlist
},
number
=
5000
)
taille
:
int
)
->
float
:
L
.
append
(
t
)
"""
times
.
append
(
time
)
renvoie: le nombre moyen de comparaisons effectuées par l
'
algo tri
pour trier des listes de taille t, la moyenne étant calculée
plt
.
plot
(
lengths
,
times
,
label
=
'
Selection Sort
'
)
sur n listes aléatoires.
plt
.
xlabel
(
'
Length of List
'
)
précondition: n > 0, t >= 0, la fonc
plt
.
ylabel
(
'
Time (s)
'
)
"""
plt
.
title
(
'
Selection Sort Execution Time
'
)
res
=
0
plt
.
legend
()
for
i
in
range
(
nbre_essais
):
plt
.
grid
(
True
)
compare
.
counter
=
0
plt
.
show
()
l
=
[
k
for
k
in
range
(
taille
)]
shuffle
(
l
)
#3
tri
(
l
,
compare
)
import
timeit
res
+=
compare
.
counter
import
matplotlib.pyplot
as
plt
return
res
/
nbre_essais
import
random
from
analyse_tris
import
tri_insert
Nmax
=
100
Nmax
=
100
number
=
5000
number
=
5000
...
@@ -80,8 +80,3 @@ plt.legend()
...
@@ -80,8 +80,3 @@ plt.legend()
plt
.
grid
(
True
)
plt
.
grid
(
True
)
plt
.
show
()
plt
.
show
()
This diff is collapsed.
Click to expand it.
tp7/tris_nbcomp.png
+
0
−
0
View replaced file @
c05172cb
View file @
60556cd7
28.7 KiB
|
W:
|
H:
28.9 KiB
|
W:
|
H:
2-up
Swipe
Onion skin
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