teaching:progappchim:tris

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
teaching:progappchim:tris [2017/02/24 12:18] villersdteaching:progappchim:tris [2022/12/09 14:25] (Version actuelle) villersd
Ligne 42: Ligne 42:
     pivot = li[0]     pivot = li[0]
     return quicksort([x for x in li[1:] if x <= pivot]) + [pivot] + quicksort([x for x in li[1:] if x > pivot])     return quicksort([x for x in li[1:] if x <= pivot]) + [pivot] + quicksort([x for x in li[1:] if x > pivot])
 +...
 +</code>
 +
 +Variante avec choix aléatoire du pivot (en fait de son index dans la numérotation de la liste) :
 +<code python>
 +...
 +    pivot_index = randrange(len(li))
 +    pivot = li[pivot_index]
 ... ...
 </code> </code>
Ligne 54: Ligne 62:
 {{ https://pbs.twimg.com/tweet_video/CZWNISuWkAEwE3q.mp4?600 }} {{ https://pbs.twimg.com/tweet_video/CZWNISuWkAEwE3q.mp4?600 }}
  
-===== Sources de codes ===== +Cf. aussi cette autre visualisation : [[https://www.makeartwithpython.com/blog/visualizing-sort-algorithms-in-python/|Sorting Algorithms Visualized in Python]], Using Python 3 and Scikit-Image 
-(qualité à vérifier) +|  {{ https://s3-us-west-2.amazonaws.com/makeartwithpython/bubble_s.gif }}  |  {{ https://s3-us-west-2.amazonaws.com/makeartwithpython/heap_s.gif }}  |  {{ https://s3-us-west-2.amazonaws.com/makeartwithpython/quick_s.gif }}  | 
-  * [[https://github.com/thecodershub/algorithms/tree/master/python/sort]]+ 
 +===== Algorithmes inefficaces ===== 
 +  * [[wp>fr:Tri_stupide|Tri stupide]] (bogo sort)
  
 +===== Références =====
 +  * Sources de codes (qualité à vérifier) [[https://github.com/thecodershub/algorithms/tree/master/python/sort]]
 +  * [[https://realpython.com/sorting-algorithms-python/|Sorting Algorithms in Python]] Santiago Valdarrama, Real Python
  • teaching/progappchim/tris.1487935091.txt.gz
  • Dernière modification : 2017/02/24 12:18
  • de villersd