QUICKSORT ALGORITHM

QUICKSORT(A,p,r)

  1. if p<r
  2. then q <- PARTITION(A,p,r)
  3. QUICKSORT(A,p,q-1)
  4. QUICKSORT(A,q+1,r)

PARTITION(A,p,r)

  • x <- A[r]
  • i<- p-1
  • for j<- p to r-1
    • do if A[j] <= x
      • then i<- i+1
        • exchange A[i] <-> A[j]
  • exchange A[i+1] <->A[r]
  • return i+1

Read More

Leave a Reply

Your email address will not be published. Required fields are marked *