09AlgorithmicComplexityI

09AlgorithmicComplexityI - CMSC 132 Object-Oriented...

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

1 CMSC 132: Object-Oriented Programming II Algorithmic Complexity I Department of Computer Science University of Maryland, College Park

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

View Full Document
2 Algorithm Efficiency Efficiency Amount of resources used by algorithm Time, space Measuring efficiency Benchmarking Asymptotic analysis
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

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
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
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/04/2011 for the course CMSC 132 taught by Professor Padua-perez during the Spring '08 term at Maryland.

Page1 / 32

09AlgorithmicComplexityI - CMSC 132 Object-Oriented...

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

View Full Document
Ask a homework question - tutors are online