lect03 - Lecture 3 Sorting and Selection Comparison Sort In...

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

View Full Document Right Arrow Icon
Lecture 3 Sorting and Selection
Background image of page 1

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

View Full Document Right Arrow Icon
Comparison Sort ree. decision t a as viewed be can sort comparison a Therefore, parts. two into sequence input of ns permutatio all partitions comparison Each sorts. comparison are Quicksort and Heapsort Sort, Merge Sort, Insertion }. ,..., , { sequence input about n informatio order gain to elements between s comparison only use we sort, comparison a In 2 1 n a a a
Background image of page 2
Decision Tree ? 2 1 a a ? 3 2 a a ? 3 2 a a ? 3 1 a a ? 3 1 a a yes yes yes yes yes 3 , 2 , 1 no no no no no 2 , 3 , 1 2 , 1 , 3 3 , 1 , 2 1 , 3 , 2 1 , 2 , 3
Background image of page 3

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

View Full Document Right Arrow Icon
Running Time ). lg ( ) ( Thus, ! 2 satisfies ) ( depth its leaves, ! has ree decision t the Since ree. decision t the of height) (or depth the is time running case) (worst the sort, comparison a In ) ( n n n T n n T n n T = Is there a faster sorting of other type?
Background image of page 4
for - end ; 1 ]] [ [ ]] [ [ ]; [ ]]] [ [ [ begin do 1 downto ] [ for ]; 1 [ ] [ ] [ do to 2 for ; 1 ]] [ [ ]] [ [ do ] [ to 1 for ; 0 ] [ do to 1 for - - + + j A C j A C j A j A C B A length j i C i C i C k i j A C j A C A length j i C k i Counting sort 4 1, 4, 3, 1, 4, 6, 3, : A 1 0, 3, 2, 0, 2, : C 8 7, 7, 4, 2, 2, : C 4, , , , , , , : B 8 7, 6, 4, 2, 2, : C 4 ˆ 1, 4, 3, 1, 4, 6, 3, : A
Background image of page 5

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

View Full Document Right Arrow Icon
, 1 ˆ 4, 3, 1, 4, 6, 3, : A 4, , , , , 1, , : B 8 7, 6, 4, 2, 1, : C 4 1, , 4 ˆ 3, 1, 4, 6, 3, : A 4, 4, , , , 1, , : B 8 7, 5, 4, 2, 1, : C 4 1, 4, , 3 ˆ 1, 4, 6, 3, : A 4, 4, , 3, , 1,
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 26

lect03 - Lecture 3 Sorting and Selection Comparison Sort In...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online