09AlgorithmicComplexityI

09AlgorithmicComplexityI - CMSC 132: Object-Oriented...

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

View Full Document Right Arrow Icon
1 CMSC 132: Object-Oriented Programming II Algorithmic Complexity I Department of Computer Science University of Maryland, College Park
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 Algorithm Efficiency Efficiency Amount of resources used by algorithm Time, space Measuring efficiency Benchmarking Asymptotic analysis
Background image of page 2
3 Benchmarking Approach Pick some desired inputs Actually run implementation of algorithm Measure time & space needed Industry benchmarks SPEC – CPU performance MySQL – Database applications WinStone – Windows PC applications MediaBench – Multimedia applications Linpack – Numerical scientific applications
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 Benchmarking Advantages Precise information for given configuration Implementation, hardware, inputs Disadvantages Affected by configuration Data sets (often too small) a dataset that was the right size 3 years ago is likely too small now Hardware Software Affected by special cases (biased inputs) Does not measure intrinsic efficiency
Background image of page 4
5 Asymptotic Analysis Approach Mathematically analyze efficiency Calculate time as function of input size n T O( f( n ) ) T is on the order of f( n ) “Big O” notation Advantages Measures intrinsic efficiency Dominates efficiency for large input sizes Programming language, compiler, processor irrelevant
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 Search Example Number guessing game Pick a number between 1…n Guess a number Answer “correct”, “too high”, “too low” Repeat guesses until correct number guessed
Background image of page 6
7 Linear Search Algorithm Algorithm Guess number = 1 If incorrect, increment guess by 1 Repeat until correct Example Given number between 1…100 Pick 20 Guess sequence = 1, 2, 3, 4 … 20 Required 20 guesses
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 Linear Search Algorithm Analysis of # of guesses needed for 1…n If number = 1, requires 1 guess If number = n, requires n guesses On average, needs n/2 guesses Time = O( n ) = Linear time
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 32

09AlgorithmicComplexityI - CMSC 132: Object-Oriented...

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

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