Skip to content
Snippets Groups Projects
Commit 78628e2b authored by paul.albuquer's avatar paul.albuquer
Browse files

modified complexity for insertion sort, size => N in source code

parent c87ed200
No related branches found
No related tags found
No related merge requests found
Pipeline #14861 passed
...@@ -36,8 +36,8 @@ triés du tableau. ...@@ -36,8 +36,8 @@ triés du tableau.
. . . . . .
```C ```C
void tri_insertion(int size, int tab[size]) { void tri_insertion(int N, int tab[N]) {
for (int i = 1; i < size; i++) { for (int i = 1; i < N; i++) {
int tmp = tab[i]; int tmp = tab[i];
int pos = i; int pos = i;
while (pos > 0 && tab[pos - 1] > tmp) { while (pos > 0 && tab[pos - 1] > tmp) {
...@@ -55,13 +55,14 @@ void tri_insertion(int size, int tab[size]) { ...@@ -55,13 +55,14 @@ void tri_insertion(int size, int tab[size]) {
. . . . . .
* Parcours de tous les éléments (ordre $N$); placer (ordre $N$). * Parcours de tous les éléments ($N-1$ passages dans la boucle)
* Moyenne: $\mathcal{O}(N^2)$. * Placer: en moyenne $i$ comparaisons et affectations à l'étape $i$
* Moyenne: $\mathcal{O}(N^2)$
. . . . . .
* Pire des cas, liste triée à l'envers: $\mathcal{O}(N^2)$, * Pire des cas, liste triée à l'envers: $\mathcal{O}(N^2)$
* Meilleurs des cas, liste déjà triée: $\mathcal{O}(N)$, * Meilleurs des cas, liste déjà triée: $\mathcal{O}(N)$
# L'algorithme à la main # L'algorithme à la main
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment