diff --git a/bubblesort.c b/bubblesort.c index a848827..07d8232 100644 --- a/bubblesort.c +++ b/bubblesort.c @@ -1,6 +1,3 @@ -// Bubblesort Algorithm -// M.Menault 2024 - void bubblesort(int* array, int length) { int swapped, i, tmp; @@ -17,5 +14,5 @@ void bubblesort(int* array, int length) swapped++; } } - } while(swapped==1); + } while(swapped > 0); } diff --git a/compte_rendu.txt b/compte_rendu.txt new file mode 100644 index 0000000..11942b7 --- /dev/null +++ b/compte_rendu.txt @@ -0,0 +1,8 @@ + Flat Profile : +Temps et nombre d'éxecution de chaque fonction. + + Call Graph : +Voir arbre d'appel + temps et nb d'exec par fonction + +Fonction la plus lente : bubblesort +nombre d'appel important de bubblesort dans find_rank_student \ No newline at end of file diff --git a/gmon.out b/gmon.out new file mode 100644 index 0000000..db395a5 Binary files /dev/null and b/gmon.out differ diff --git a/heapsort.c b/heapsort.c index 668f4b7..9c983ea 100644 --- a/heapsort.c +++ b/heapsort.c @@ -1,5 +1,4 @@ -// Heapsort Algorithm -// M.Menault 2024 + #include #include @@ -47,13 +46,12 @@ void heapsort(int* array, int length) { int i = 0; int temp_value = 0; - - // Sift the current array (binary tree) + for(i=(length/2); i >= 0; i--) { sift(array,i,length); } - // Heapsort ! + for(i=length-1; i > 0; i--) { temp_value = array[i]; diff --git a/student_rank b/student_rank new file mode 100755 index 0000000..3ca874c Binary files /dev/null and b/student_rank differ diff --git a/student_rank.c b/student_rank.c index af84003..d58080b 100644 --- a/student_rank.c +++ b/student_rank.c @@ -1,5 +1,4 @@ -// Student rank -// M.Menault 2024 + #include #include @@ -55,7 +54,7 @@ int find_rank_student(int student_grade, int* grades_array, int students_number) { int position = -1; int i = 0; - bubblesort(grades_array,students_number); + /*bubblesort(grades_array,students_number);*/ for(i = students_number-1; i >= 0; i--) { if(grades_array[i] == student_grade) @@ -77,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);