diff --git a/Résultat.txt b/Résultat.txt index 069614a..5a16c66 100644 --- a/Résultat.txt +++ b/Résultat.txt @@ -50,4 +50,6 @@ index % time self children called name [8] 0.0 0.00 0.00 1 generate_ranks [8] ----------------------------------------------- -Il faut supprimer le bubblesort qui est dans la fonction find_rank_student pour gagner du temps sauf qu'on ne gagne pas assez de temps pour passer en dessous d'une secondes. \ No newline at end of file +On modifie d'abord bubblesort pour qu'il fonctionne correctement en remplaçant swapped ++ par swapped = 1. +Ensuite on supprime le bubblesort qui est dans la fonction find_rank_student pour gagner du temps sauf qu'on ne gagne pas assez de temps pour passer en dessous d'une secondes. +Quand on remplace le bubblesort restant par heapsort, c'est beacoup plus rapide sauf que le tri ne ce fait pas bien. diff --git a/bubblesort.c b/bubblesort.c index 7961fe4..3686a45 100644 --- a/bubblesort.c +++ b/bubblesort.c @@ -14,7 +14,7 @@ void bubblesort(int* array, int length) tmp = array[i-1]; array[i-1] = array[i]; array[i] = tmp; - swapped = 1; + swapped= 1; } } } while(swapped==1); diff --git a/gmon.out b/gmon.out index 002973f..c5ffa87 100644 Binary files a/gmon.out and b/gmon.out differ diff --git a/student_rank b/student_rank index e6de7eb..3c99d85 100755 Binary files a/student_rank and b/student_rank differ diff --git a/student_rank.c b/student_rank.c index c6dc75a..6620a4d 100644 --- a/student_rank.c +++ b/student_rank.c @@ -76,7 +76,7 @@ void sort_students(int** students_rank, int** students_array, int students_numbe { grades[j] = students_array[j][i]; } - bubblesort(grades,students_number); + heapsort(grades,students_number); for(j = 0; j < students_number; j++) { students_rank[j][i] = find_rank_student(students_array[j][i],grades,students_number);