Sorting1.9

# Sorting1.9 - QuickSort Invented by C.A.R Hoare in 1960...

This preview shows pages 1–5. Sign up to view the full content.

Last Updated: 4/1/10 11:16 AM CSE 2011 Prof. J. Elder - 46 - QuickSort ± Invented by C.A.R. Hoare in 1960 ± “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Last Updated: 4/1/10 11:16 AM CSE 2011 Prof. J. Elder - 47 - Quick-Sort ± Quick-sort is a divide-and- conquer algorithm: ² Divide : pick a random element x (called a pivot ) and partition S into ³ L elements less than x ³ E elements equal to x ³ G elements greater than x ² Recur : Quick-sort L and G ² Conquer : join L , E and G x x L G E x
Last Updated: 4/1/10 11:16 AM CSE 2011 Prof. J. Elder - 48 - The Quick-Sort Algorithm Algorithm QuickSort (S) if S.size() > 1 (L, E, G) = Partition(S) QuickSort(L) QuickSort(G) S = (L, E, G)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Last Updated: 4/1/10 11:16 AM CSE 2011 Prof. J. Elder - 49 - Partition ± Remove, in turn, each element y from S and ± Insert y into sequence L , E or G , depending on the result of the comparison with the pivot
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern