notes95

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

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
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

Page1 / 3

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 Right Arrow Icon
Ask a homework question - tutors are online