25.06.2013 Views

1 transparent par page - Montefiore

1 transparent par page - Montefiore

1 transparent par page - Montefiore

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Quicksort<br />

Partition(A, lo, hi)<br />

1 i = lo ; j = hi + 1 ;v = A[lo]<br />

2 while (true)<br />

3 repeat i = i + 1 until A[i] >= v<br />

4 repeat j = j − 1 until A[j] = j)<br />

6 break<br />

7 swap(A[i], A[j])<br />

8 swap(A[lo], A[j]) ;<br />

9 return j<br />

◮ Opération de base : com<strong>par</strong>aison<br />

◮ Modèle d’entrée :<br />

◮ Tableau A ordonné aléatoirement<br />

◮ Toutes les valeurs de A sont différentes<br />

QuickSort(A, lo, hi)<br />

1 if begin < end<br />

2 q = Partition(A, lo, hi)<br />

3 QuickSort(A, lo, q − 1)<br />

4 QuickSort(A, q + 1, hi)<br />

◮ Hypothèse : temps de calcul est ∼ aCN où a est une constante et<br />

CN est le nombre de com<strong>par</strong>aisons.<br />

299

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!