true

Take BTech Tuition from the Best Tutors

• Affordable fees
• 1-1 or Group class
• Flexible Timings
• Verified Tutors

Search in

# Quick Sort Algorithm

D Subba Rao
23/08/2017 0 0
1. Choose the pivot (using the "median-of-three" technique); also, put the smallest of the 3 values in A[low], put the largest of the 3 values in A[high], and swap the pivot with the value in A[high-1]. (Putting the smallest value in A[low] prevents right from falling off the end of the array in the following steps.)
2. Initialize: left = low+1; right = high-2
3. Use a loop with the condition:

while (left <= right)

The loop invariant is:

all items in A[low] to A[left-1] are <= the pivot
all items in A[right+1] to A[high] are >= the pivot

Each time around the loop:

left is incremented until it "points" to a value > the pivot
right is decremented until it "points" to a value < the pivot
if left and right have not crossed each other,
then swap the items they "point" to.

1. Put the pivot into its final place.
0 Dislike

## Other Lessons for You

Java 9 , the new beginning
Java 9 is here! A major feature release in the Java Platform Standard Edition is Java 9 Lets see what more it offers more than its previous versions Java platform module JEP 223 : New version...
G

GCC

Computer Awareness
A Computer is an electronic device that can be instructed to carry out an arbitrary set of arithmetic or logical operations automatically. 1. Introduction: i. Speed: The speed of computation is very...
P

Parul S.

Computer Awareness: Important Abbreviations
Important Abbreviations:1. ANSI: American National Standards Institute. 2. ASCII: American Standard Code for Information Interchange. 3. CGA: Colour Graphics Adapter. 4. DOS: Disk Operating System. 5....
P

Parul S.

A Tutorial On Dynamic Programming
What is Dynamic Programming? Dynamic Programming, DP in short, is an intelligent way of solving a special type of complex problems which otherwise would hardly be solved in realistic time frame. What...

What Is The Difference Between Scope And Lifetime?
Scope of a variable is defined as the block of code from where we can refer or access it. On the other hand the life time of a variable is defined as the time in between allocating memory for it and relinquishing...

### Looking for BTech Tuition ?

Learn from Best Tutors on UrbanPro.

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

### Looking for BTech Tuition Classes?

The best tutors for BTech Tuition Classes are on UrbanPro

• Select the best Tutor
• Book & Attend a Free Demo
• Pay and start Learning

### Take BTech Tuition with the Best Tutors

The best Tutors for BTech Tuition Classes are on UrbanPro