ECE
Lecture 16

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

• Notes
• 29

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

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

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

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 ?
How do we measure time? Consider the following examples: Is there any signi fi cant difference ?

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

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 ?
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

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

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
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

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