Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Projet_Pne
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
AlifIhsan Syauqi
Projet_Pne
Commits
300dbb04
Commit
300dbb04
authored
6 days ago
by
AlifIhsan Syauqi
Browse files
Options
Downloads
Patches
Plain Diff
readme
parent
ed6dc05d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
readme.md
+139
-0
139 additions, 0 deletions
readme.md
with
139 additions
and
0 deletions
readme.md
+
139
−
0
View file @
300dbb04
# Projet_Pne
# METHODE DE QUICKSORT
# FONCTION PARTITION
static void partition(list_t
* L, elmlist_t *
pivot, list_t
* val_inf, list_t *
val_sup, int (
*cmpFct)(void*
, void
*
)) {
for (elmlist_t
*
cur = L->head; cur != NULL; cur = cur->suc) { //on parcourt la liste de la tête jusqu'à 0
if (cmpFct(get_data(cur), get_data(pivot)) < 0) //cmpfct va decider si le data est inferiur
queue(val_inf, get_data(cur));
else
queue(val_sup, get_data(cur));
}
}
# FONCTION QUICKSORT
# Etape (1)
void quick_sort(list_t
* L, int (*
cmpFct)(void
*, void*
)) {
assert(L && cmpFct); //on verifier L et CmpFct
if (L->numelm > 1) {
elmlist_t
*
pivot = get_head(L); //la tete sera un pivot et on le retire de la liste
L->head = get_suc(pivot);
pivot->pred = NULL;
pivot->suc = NULL;
}
# Etape (2)
//on créer deux nouveaux liste
list_t
*
val_inf_pivot = new_list();
list_t
*
val_sup_pivot = new_list();
# Etape (3)
//on appelle le fonction partition
partition(L,pivot,val_inf_pivot,val_sup_pivot,cmpFct);
# Etape (4)
if (is_empty(val_inf_pivot)) { //le liste sera le pivot s'il n'y en a pas
L->head = pivot;
L->tail = pivot;
L->numelm = 1;
} else {
quick_sort(val_inf_pivot, cmpFct);
L->head = val_inf_pivot->head;
L->tail = val_inf_pivot->tail;
L->numelm = val_inf_pivot->numelm;
pivot->pred = L->tail;
L->tail->suc = pivot;
L->tail = pivot;
L->numelm += 1;
}
if (!is_empty(val_sup_pivot)) {
quick_sort(val_sup_pivot, cmpFct);
val_sup_pivot->head->pred = pivot;
pivot->suc = val_sup_pivot->head;
L->tail = val_sup_pivot->tail;
L->numelm += val_sup_pivot->numelm;
}
# Etape (5)
//on liberé leur pointeur respectif
free(val_inf_pivot);
free(val_sup_pivot);
}
}
#outils
git remote add origin https://gitlab.univ-lorraine.fr/e87374u/projet_pne.git
git branch -M main
git push -uf origin main
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