Quick sort algorithm
Content covered: 

Quick sort algorithm : QuickSort is a Divide and Conquer algorithm. It picks an element as pivot and partitions the given array around the picked pivot.

QuickSort (A, p, r)

  1. If p < r then
  2.     q Partition (Ap, r)
  3.     Recursive call to Quick Sort (Apq)
  4.     Recursive call to Quick Sort (A+ rr)

PARTITION (Apr)

  1. x ← A[p]
  2. i ← p-1
  3. j ← r+1
  4. while TRUE do
  5.     Repeat j ← j-1
  6.     until A[j] ≤ x
  7.     Repeat i ← i+1
  8.     until A[i] ≥ x
  9.     if i < j
  10.         then exchange A[i] ↔ A[j]
  11.         else return j
More Less
0Comment