Algorithm Analysis

Algorithm Analysis - Algorithm Analysis An algorithm is a...

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

View Full Document Right Arrow Icon
1 Algorithm Analysis z An algorithm is a clearly specified set of simple instructions to be followed to solve a problem. – How to estimate the running time ; – How to reduce the running time of a program from days to fractions of a second; – What is the storage complexity of the program. – How to deal with the trade-offs.
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Running Time of a Program z There are two contradictory goals: – We would like an algorithm that is easy to understand, code, and debug. – We would like an algorithm that makes efficient use of the computer's resources, especially, one that runs as fast as possible.
Background image of page 2
3 Function Comparison z Given two functions, f ( N ) and g ( N ), what does it mean when we say that f ( N ) < g ( N )? – Should this hold for all N ? – We need to compare their relative rates of growth.
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Definitions z T ( N ) = O ( f ( N )) if there are positive constants c and n 0 such that T ( N ) c f ( N ) when N n 0 . z T ( N ) = ( g ( N )) if there are positive constants c and n 0 such that T ( N ) c g ( N ) when N n 0 . z T ( N ) = Θ ( h ( N )) if and only if T ( N ) = O ( h ( N )) and T ( N ) = ( h ( N )). z T ( N ) = o( p ( N )) if T ( N ) = O ( p ( N )) and T ( N ) Θ ( p ( N )).
Background image of page 4
5 Example
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Why? z The idea is to establish a relative order among functions. z We are more concerned about the relative rates of growth of functions. z For example, which function is greater, 1,000 N or N 2 ? z The turning point is n 0 = 1,000 where N 2 will be greater for larger N .
Background image of page 6
7 First Definition O z It says that there is some point n 0 past which cf ( N ) is always at least as large as T ( N ). z In our case, T ( N ) = 1000 N , f ( N ) = N 2 , n 0 = 1,000, and c = 1. z We could also use n 0 = 10, and c = 100. z So we can say that 1000 N = O ( N 2 ). z It is an upper bound on T ( N ).
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 Others z The second definition says that the growth rate of T ( N ) is greater than or equal to that of g ( N ). z The third definition Θ says that the growth rate of T ( N ) equals the growth rate of h ( N ). z The fourth definition o says that the growth rate of T ( N ) is less than the growth rate of p ( N ).
Background image of page 8
Big-O Notation z If f ( n ) and g ( n ) are functions defined for positive integers, then to write f ( n ) is O ( g ( n )) z read f ( n ) is big Oh of g ( n ) means that there exists a constant c such that | f ( n )| c | g ( n )| for all sufficiently large positive integers n . z
Background image of page 9

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

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 38

Algorithm Analysis - Algorithm Analysis An algorithm is a...

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

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