Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cours
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
aurelien.boyer
cours
Commits
ac9e20b6
Verified
Commit
ac9e20b6
authored
2 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
corrected typos
parent
080abb51
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
slides/cours_7.md
+14
-8
14 additions, 8 deletions
slides/cours_7.md
with
14 additions
and
8 deletions
slides/cours_7.md
+
14
−
8
View file @
ac9e20b6
...
...
@@ -149,36 +149,42 @@ Non c'est normal, faisons un exemple.
# Tri rapide ou quicksort (3/8)
\f
ootnotesize
Deux variables sont primordiales:
```
C
i
nt
low, high
; // les indices min/max des tableaux à trier
e
nt
ier int_min, ind_max
; // les indices min/max des tableaux à trier
```

# Tri rapide ou quicksort (4/8)
\f
ootnotesize
Deux variables sont primordiales:
```
C
i
nt
low, high
; // les indices min/max des tableaux à trier
e
nt
ier ind_min, ind_max
; // les indices min/max des tableaux à trier
```
## Pseudocode: quicksort
```
python
rien
quicksort
(
entier
tableau
[],
ind_min
,
ind_max
)
rien
quicksort
(
entier
tableau
[],
entier
ind_min
,
entier
ind_max
)
si
(
longueur
(
tab
)
>
1
)
ind_pivot
=
partition
(
array
,
ind_min
,
ind_max
)
si
(
longueur
(
tableau
[
0
:
ind_pivot
-
1
])
!=
0
)
quicksort
(
tableau
,
ind_min
,
pivot_ind
-
1
)
;
quicksort
(
tableau
,
ind_min
,
pivot_ind
-
1
)
si
(
longueur
(
tableau
[
ind_pivot
+
1
:
ind_max
-
1
])
!=
0
)
quicksort
(
tableau
,
ind_pivot
+
1
,
ind_max
)
```
# Tri rapide ou quicksort (5/8)
\f
ootnotesize
## Pseudocode: partition
```
C
...
...
@@ -187,9 +193,9 @@ entier partition(entier tableau[], entier ind_min, entier ind_max)
i = ind_min;
j = ind_max-1;
tant que i < j:
en remontant i trouver le premier élément > pivot
;
en descendant j trouver le premier élément < pivot
;
échanger(array[i], array[j])
;
en remontant i trouver le premier élément > pivot
en descendant j trouver le premier élément < pivot
échanger(array[i], array[j])
// les plus grands à droite
// mettre les plus petits à gauche
...
...
@@ -325,7 +331,7 @@ rien tri_a_bulles(entier tableau[])
trié = vrai
pour j de 0 à i-1:
si (tableau[j] > tableau[j+1])
swap
(array[j], array[j+1])
échanger
(array[j], array[j+1])
trié = faux
si trié
...
...
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