Quicksort

Quicksort

Quicksort is depended on the divide and conquer technique. Set is reduced by sorting two smallest sets.

Quicksort

Steps:
Step-1: Identify the key value.
Step-2: Scan from R->L stopping at value < key Interchange value & key
Step-3: Scan from L->R stopping at value > key Interchange value & key
Step-4: Continued step 2 & 3

Perform QUICKSORT on the given data: 44 33 11 55 77 90 40 60 99 22 88 66

Quicksort working
Quicksort working
Quicksort working
Quicksort working
Quicksort working
Quicksort working
Quicksort working

After Quick Sort Array will be:

Final Quicksort working

Algorithm

 A is an array with N element
  1.[Initialize] set left = 1
  Right=N, loc=1,key=A[loc]
  2.[Scan from Right to Left]
  		a. Repeat while key A[Right]
        		Interchange key & A[Right]
        d. set loc = Right
        		Go to step 3.
   3.[Scan from left to Right]
   		a. Repeat while A[left]<=key
        		left=left+1
        b. if loc = left , them Return.
        c. if A[left] > key 
        		Interchange A[left] & key
        d. set loc= left
           Go to 3

Leave a Comment

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

Scroll to Top