notes95

# notes95 - Quick Sort Popular sorting algorithm that also...

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

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Quick Sort Popular sorting algorithm that also uses divide and conquer. void quicksort(S) Input: unsorted array S Output : sorted array S 1. Divide If S has only 1 element then return else{- choose an element X in S that we will call pivot- Divide S into 3 sets L, E, G where the elements in L are less than X the elements in G are greater than X the elements in E are equal to X 2. Recur quicksort(L) quicksort(G) 3. Conquer put elements of L, E, G back into S Eg: quicksort(7, 6, 2, 10, 4, 5, 9, 8) pivot L E G qs(7, 6, 2, 4, 5) 8 qs(10, 9) L E G L...
View Full Document

## notes95 - Quick Sort Popular sorting algorithm that also...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online