lecture10

# lecture10 - Heaps Heap Sort IE170 Algorithms in Systems...

This preview shows pages 1–3. 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: Heaps Heap Sort IE170: Algorithms in Systems Engineering: Lecture 10 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University February 5, 2007 Jeff Linderoth IE170:Lecture 10 Heaps Heap Sort What We’ve Learned 1 Summation Formulae, Induction and Bounding 2 How to compare functions: o, ω, O, Ω , Θ 3 How to count the running time of algorithms 4 How to solve recurrences that occur when we do (3) 5 Data Structures: Hash Binary Search Trees Heap Jeff Linderoth IE170:Lecture 10 Heaps Heap Sort The World’s First Algorithm Euclid’s Algorithm ( m, n ) 1 Divide m by n and let r be the remainder. 2 If r = 0 , then gcd( m, n ) = n . 3 Otherwise, gcd( m, n ) = gcd( n, r ) Jeff Linderoth IE170:Lecture 10 Heaps Heap Sort Summation Formulae Arithmetic Series 1 + 2 + ··· + n = n k =1 k = n ( n + 1) 2 Sum Of Squares n k =0 k 2 = n ( n + 1)(2 n + 1) 6 Often, such formulae can be proved via mathematical induction Jeff Linderoth IE170:Lecture 10 Heaps Heap Sort Geometric Series n k =0 x k = 1- x n +1 1- x If | x | < 1 , then the series converges to ∞ k =0 x k = 1 1- x . Harmonic Series H n = 1 + 1 2 + 1 3 + ··· + 1 k = n k =1 1 k ≈ ln( n ) Jeff Linderoth IE170:Lecture 10 Heaps Heap Sort Bounding Sums by Integrals When f is a (monotonically) increasing function, then we can approximate the sum ∑ n k = m f ( k ) by the integrals: n m- 1 f ( x ) dx ≤ n k = m f ( k ) ≤ n +1 m f ( x ) dx. and a decreasing function can be approximated by n +1 m f ( x ) dx ≤ n k = m f ( k ) ≤ n m- 1 f ( x ) dx Jeff Linderoth IE170:Lecture 10 Heaps Heap Sort O, Ω , Θ definitions Θ( g ) = { f : ∃ c 1 , c 2 , n > 0 such that c 1 g ( n ) ≤ f ( n ) ≤ c 2 g ( n ) ∀ n ≥ n } Ω( g ) = { f | ∃ constants c, n > s.t. ≤ cg ( n ) ≤ f ( n ) ∀ n ≥ n } O ( g ) = { f | ∃ constants c, n > 0 s.t. f ( n ) ≤ cg ( n ) ∀ n ≥ n } Jeff Linderoth IE170:Lecture 10 Heaps Heap Sort o, ω Notation f ∈ o ( g ) ⇔ lim n →∞ f ( n ) g ( n ) = 0 f ∈ ω ( g ) ⇔ g ∈ o ( f ) ⇔ lim n →∞ f ( n ) g ( n ) = ∞ f ∈ Θ( g ) ⇔ lim n →∞ f ( n ) g ( n ) = c f ∈ o ( g ) ⇒ f ∈ O ( g ) \ Θ( g ) . f ∈ ω ( g ) ⇒ f ∈ O ( g ) \ Θ( g ) ....
View Full Document

{[ snackBarMessage ]}

### Page1 / 8

lecture10 - Heaps Heap Sort IE170 Algorithms in Systems...

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

View Full Document
Ask a homework question - tutors are online