Lecture 16 - ECE 2574 Introduction to Data Structures and...

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

View Full Document Right Arrow Icon
ECE 2574 Introduction to Data Structures and Algorithms Lecture 16: Algorithm Complexity and “Big-O” Notation Reading: Chapter 9 Chris Wyatt Electrical and Computer Engineering and School of Biomedical Engineering and Sciences Virginia Tech
Image of page 1

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

View Full Document Right Arrow Icon
Algorithm Ef fi ciency What does it mean to say algorithm A is more ef fi cient than algorithm B? ef fi cient: achieving results without wasted time or effort Time: How long does it take? Space: How much memory does it take ? Power: How much power does it consume ?
Image of page 2
How do we measure time? Consider the following examples: Is there any signi fi cant difference ?
Image of page 3

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

View Full Document Right Arrow Icon
Problems comparing algorithms by their implementation. 1. How are the algorithms coded, which language, style? 2. What machine is used to test ? 3. What data should be used to test ?
Image of page 4
Algorithm Analysis uses mathematical techniques to quantify complexity in terms of basic operations . The total operations typically depend on the number of data required, n. Basic operations are those that all languages support - additions, subtractions, multiply, divide - comparisons - assignments and/or function calls
Image of page 5

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

View Full Document Right Arrow Icon
What if each operation takes a different unit of time? Example: Let a and c be the unit of time required to perform an assignment and comparison respectively. Then the total time is a + n*a + (n+1)c
Image of page 6
Example: Towers of Hanoi, number of moves. Move N disks from peg A to peg B, using C as an intermediary, at all times disks must be ordered largest to smallest vertically. A B C
Image of page 7

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

View Full Document Right Arrow Icon