1 / 10

Algorithme Les tris

Algorithme Les tris. Par :Hicham EL’mbarki T.D.I GROUPE:B 2009. Le tri par sélection :. Dans ce tri on cherche le plus petit élément du tableau et on le place en 1 er , puis on cherche le plus petit dans ce qui reste et on le met en second , etc.….

eyad
Download Presentation

Algorithme Les tris

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Algorithme Les tris Par :Hicham EL’mbarki T.D.I GROUPE:B 2009

  2. Le tri par sélection : • Dans ce tri on cherche le plus petit élément du tableau et on le place en 1er , puis on cherche le plus petit dans ce qui reste et on le met en second , etc.…..

  3. Exemple :

  4. Explication: min ←t(1) Si min >t(i) alors min ← t(i) pos ← i fin si fin

  5. Algorithme: Algo tri par sélection Var: Tableau T(10):entier i , j, pos, petit : entier Début Pour i = 1à 9 faire petit ← T(i) pour j = i à 10 faire si T(j)< petit alors petit ←T(j) fin si pour j = pos à i+1 pas -1 faire T(j) ← petit Fin pour j Fin pour i fin

  6. Le tri par bulle: • Un tri par bulle est un tri astucieux , son principe est de faire remonter petit à petit un élément trop grand vers le haut du tableau en comparent les élément deux à deux . • Si l’élément de gauche est supérieur à son voisin de droit on les inverse et on continue avec le suivant .Lorsque l’on est en haut du tableau on repart au début et on s’ arrête lorsque tous les élément sont bien placés.

  7. Exemple :

  8. Explication: Si t(1) >t(2) alors v ← t(1) T(1) ← t(2) t(2) ←v Fin si sin

  9. Algorithme: Algo tri par bulle Var : tableau t(i),t(i+1) i , tampon , inversion , vrai : booléen Début inversion ← vrai Pour i = 1à 9 faire Si t(i) >t(i+1) alors tampon ← t(i) T(i) ← t(i+1) t(i+1) ← tampon inversion ← vrai Fin si Fin pour i fin

  10. Fin.

More Related