Design and Analysis of Algorithms. DAA: Proof by Induction Asymptotic Notation
Design and Analysis of Algorithms. DAA: Proof by Induction Asymptotic Notation
DAA
SP09-A CR 03017272312 Introduction SP09-B CR 03336792345 Proof By Induction FA09-A CR 03457729022 Asymptotic notation
The Course
Purpose: a rigorous introduction to the design and analysis of algorithms
Not a lab or programming course Not a math course, either
(David Luebke) Edited By Usman Akram & Atif Saeed
The Course
Instructor: Muhammad Usman Akram
[email protected] Office: Graduate School Room-5 One hour right after each class
(David Luebke) Edited By Usman Akram & Atif Saeed
The Course
Grading policy:
Quizzes and Assignments: 25% Exam 1: 10% Exam 2: 15% Final: 50%
The Course
Prerequisites:
Data Structures Discrete Structures
(David Luebke) Edited By Usman Akram & Atif Saeed
The Course
Format
Two lectures/week Homework most weeks
(David Luebke) Edited By Usman Akram & Atif Saeed
Review: Induction
Suppose
S(k) is true for fixed constant k
Often k = 0
Proof By Induction
Claim:S(n) is true for all n >= k Basis:
Show formula is true when n = k Assume formula is true for an arbitrary n
(David Luebke) Edited By Usman Akram & Atif Saeed
Inductive hypothesis:
Step:
Show that formula is then true for n+1
Inductive hypothesis:
Assume 1 + 2 + 3 + + n = n(n+1) / 2
Inductive hypothesis:
Induction
Weve been using weak induction Strong induction also holds
(David Luebke) Edited By Usman Akram & Atif Saeed
Basis: show S(0) Hypothesis: assume S(k) holds for arbitrary k <= n Step: Show S(n+1) follows
Another variation:
Basis: show S(0), S(1) Hypothesis: assume S(n) and S(n+1) are true Step: show S(n+2) follows
Asymptotic Performance
In this course, we care most about asymptotic performance
How does the algorithm behave as the problem size gets very large?
(David Luebke) Edited By Usman Akram & Atif Saeed
Asymptotic Notation
By now you should have an intuitive feel for asymptotic (bigO) notation:
What does O(n) running time mean? O(n2)? O(n lg n)? How does asymptotic running time relate to asymptotic memory usage?
Our first task is to define this notation more formally and completely
Analysis of Algorithms
Analysis is performed with respect to a computational model We will usually use a generic uniprocessor random-access machine (RAM)
(David Luebke) Edited By Usman Akram & Atif Saeed
All memory equally expensive to access No concurrent operations All reasonable instructions take unit time
Except, of course, function calls
Input Size
Time and space complexity
This is generally a function of the input size
E.g., sorting, multiplication
Sorting: number of input items Multiplication: total number of bits Graph algorithms: number of nodes & edges Etc
Running Time
Number of primitive steps that are executed
Except for time of executing a function call most statements roughly require the same amount of time
(David Luebke) Edited By Usman Akram & Atif Saeed
Analysis
Worst case
Provides an upper bound on running time An absolute guarantee
Average case
Provides the expected running time Very useful, but treat with care: what is average?
Random (equally likely) inputs Real-life inputs
(David Luebke) Edited By Usman Akram & Atif Saeed
The End