SlideShare a Scribd company logo
David Luebke 1 8/29/2022
CS 332: Algorithms
Introduction
Proof By Induction
Asymptotic notation
David Luebke 2 8/29/2022
The Course
• Purpose: a rigorous introduction to the design
and analysis of algorithms
 Not a lab or programming course
 Not a math course, either
• Textbook: Introduction to Algorithms, Cormen,
Leiserson, Rivest, Stein
 The “Big White Book”
 Second edition: now “Smaller Green Book”
 An excellent reference you should own
David Luebke 3 8/29/2022
The Course
• Instructor: David Luebke
 luebke@cs.virginia.edu
 Office: Olsson 219
 Office hours: 2-3 Monday, 10-11 Thursday
• TA: Pavel Sorokin
 Office hours and location TBA
David Luebke 4 8/29/2022
The Course
• Grading policy:
 Homework: 30%
 Exam 1: 15%
 Exam 2: 15%
 Final: 35%
 Participation: 5%
David Luebke 5 8/29/2022
The Course
• Prerequisites:
 CS 202 w/ grade of C- or better
 CS 216 w/ grade of C- or better
 CS 302 recommended but not required
o Who has not taken CS 302?
David Luebke 6 8/29/2022
The Course
• Format
 Three lectures/week
 Homework most weeks
o Problem sets
o Maybe occasional programming assignments
 Two tests + final exam
David Luebke 7 8/29/2022
Review: Induction
• Suppose
 S(k) is true for fixed constant k
o Often k = 0
 S(n)  S(n+1) for all n >= k
• Then S(n) is true for all n >= k
David Luebke 8 8/29/2022
Proof By Induction
• Claim:S(n) is true for all n >= k
• Basis:
 Show formula is true when n = k
• Inductive hypothesis:
 Assume formula is true for an arbitrary n
• Step:
 Show that formula is then true for n+1
David Luebke 9 8/29/2022
Induction Example:
Gaussian Closed Form
• Prove 1 + 2 + 3 + … + n = n(n+1) / 2
 Basis:
o If n = 0, then 0 = 0(0+1) / 2
 Inductive hypothesis:
o Assume 1 + 2 + 3 + … + n = n(n+1) / 2
 Step (show true for n+1):
1 + 2 + … + n + n+1 = (1 + 2 + …+ n) + (n+1)
= n(n+1)/2 + n+1 = [n(n+1) + 2(n+1)]/2
= (n+1)(n+2)/2 = (n+1)(n+1 + 1) / 2
David Luebke 10 8/29/2022
Induction Example:
Geometric Closed Form
• Prove a0 + a1 + … + an = (an+1 - 1)/(a - 1) for
all a  1
 Basis: show that a0 = (a0+1 - 1)/(a - 1)
a0 = 1 = (a1 - 1)/(a - 1)
 Inductive hypothesis:
o Assume a0 + a1 + … + an = (an+1 - 1)/(a - 1)
 Step (show true for n+1):
a0 + a1 + … + an+1 = a0 + a1 + … + an + an+1
= (an+1 - 1)/(a - 1) + an+1 = (an+1+1 - 1)/(a - 1)
David Luebke 11 8/29/2022
Induction
• We’ve been using weak induction
• Strong induction also holds
 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
David Luebke 12 8/29/2022
Asymptotic Performance
• In this course, we care most about asymptotic
performance
 How does the algorithm behave as the problem
size gets very large?
o Running time
o Memory/storage requirements
o Bandwidth/power requirements/logic gates/etc.
David Luebke 13 8/29/2022
Asymptotic Notation
• By now you should have an intuitive feel for
asymptotic (big-O) 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
David Luebke 14 8/29/2022
Analysis of Algorithms
• Analysis is performed with respect to a
computational model
• We will usually use a generic uniprocessor
random-access machine (RAM)
 All memory equally expensive to access
 No concurrent operations
 All reasonable instructions take unit time
o Except, of course, function calls
 Constant word size
o Unless we are explicitly manipulating bits
David Luebke 15 8/29/2022
Input Size
• Time and space complexity
 This is generally a function of the input size
o E.g., sorting, multiplication
 How we characterize input size depends:
o Sorting: number of input items
o Multiplication: total number of bits
o Graph algorithms: number of nodes & edges
o Etc
David Luebke 16 8/29/2022
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
o y = m * x + b
o c = 5 / 9 * (t - 32 )
o z = f(x) + g(y)
• We can be more exact if need be
David Luebke 17 8/29/2022
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”?
o Random (equally likely) inputs
o Real-life inputs
David Luebke 18 8/29/2022
The End

More Related Content

Similar to lecture1.ppt

Civil Engineering Skills - Introduction
Civil Engineering Skills - IntroductionCivil Engineering Skills - Introduction
Civil Engineering Skills - Introduction
TUOS-Sam
 
Zvi random-walks-slideshare
Zvi random-walks-slideshareZvi random-walks-slideshare
Zvi random-walks-slideshare
Zvi Lotker
 
Module I CSAS_105152.pdf
Module I CSAS_105152.pdfModule I CSAS_105152.pdf
Module I CSAS_105152.pdf
Kovendan Akp
 
Asufe juniors-training session2
Asufe juniors-training session2Asufe juniors-training session2
Asufe juniors-training session2
Omar Ahmed
 
Outline
OutlineOutline
Outline
mehr78
 
lecture7.ppt
lecture7.pptlecture7.ppt
lecture7.ppt
PallaviDhade1
 
Hash table
Hash tableHash table
Hash table
Rajendran
 
Ch 06 - CPM PERT (1).pptx
Ch 06 - CPM  PERT (1).pptxCh 06 - CPM  PERT (1).pptx
Ch 06 - CPM PERT (1).pptx
sitinorhafizabintiab1
 
02-tradition-ml.pdf
02-tradition-ml.pdf02-tradition-ml.pdf
02-tradition-ml.pdf
KarasuLee
 
Using timed-release cryptography to mitigate the preservation risk of embargo...
Using timed-release cryptography to mitigate the preservation risk of embargo...Using timed-release cryptography to mitigate the preservation risk of embargo...
Using timed-release cryptography to mitigate the preservation risk of embargo...
Michael Nelson
 
Computational thinking copy (1)
Computational thinking copy (1)Computational thinking copy (1)
Computational thinking copy (1)
EllenHarp1
 
CS-102 DS-class_01_02 Lectures Data .pdf
CS-102 DS-class_01_02 Lectures Data .pdfCS-102 DS-class_01_02 Lectures Data .pdf
CS-102 DS-class_01_02 Lectures Data .pdf
ssuser034ce1
 
september18.ppt
september18.pptseptember18.ppt
september18.ppt
CharlesMatu2
 
Introduction to Graph Theory
Introduction to Graph TheoryIntroduction to Graph Theory
Introduction to Graph Theory
Kazi Md. Saidul
 
Lecture slides week14-15
Lecture slides week14-15Lecture slides week14-15
Lecture slides week14-15
Shani729
 
Computing on Encrypted Data
Computing on Encrypted DataComputing on Encrypted Data
Computing on Encrypted Data
New York Technology Council
 
lecture1.ppt
lecture1.pptlecture1.ppt
lecture1.ppt
RohanKharat10
 
Intro
IntroIntro
Intro
Vin Voro
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
Rajendran
 
lecture1.pdf
lecture1.pdflecture1.pdf
lecture1.pdf
Tamer Nadeem
 

Similar to lecture1.ppt (20)

Civil Engineering Skills - Introduction
Civil Engineering Skills - IntroductionCivil Engineering Skills - Introduction
Civil Engineering Skills - Introduction
 
Zvi random-walks-slideshare
Zvi random-walks-slideshareZvi random-walks-slideshare
Zvi random-walks-slideshare
 
Module I CSAS_105152.pdf
Module I CSAS_105152.pdfModule I CSAS_105152.pdf
Module I CSAS_105152.pdf
 
Asufe juniors-training session2
Asufe juniors-training session2Asufe juniors-training session2
Asufe juniors-training session2
 
Outline
OutlineOutline
Outline
 
lecture7.ppt
lecture7.pptlecture7.ppt
lecture7.ppt
 
Hash table
Hash tableHash table
Hash table
 
Ch 06 - CPM PERT (1).pptx
Ch 06 - CPM  PERT (1).pptxCh 06 - CPM  PERT (1).pptx
Ch 06 - CPM PERT (1).pptx
 
02-tradition-ml.pdf
02-tradition-ml.pdf02-tradition-ml.pdf
02-tradition-ml.pdf
 
Using timed-release cryptography to mitigate the preservation risk of embargo...
Using timed-release cryptography to mitigate the preservation risk of embargo...Using timed-release cryptography to mitigate the preservation risk of embargo...
Using timed-release cryptography to mitigate the preservation risk of embargo...
 
Computational thinking copy (1)
Computational thinking copy (1)Computational thinking copy (1)
Computational thinking copy (1)
 
CS-102 DS-class_01_02 Lectures Data .pdf
CS-102 DS-class_01_02 Lectures Data .pdfCS-102 DS-class_01_02 Lectures Data .pdf
CS-102 DS-class_01_02 Lectures Data .pdf
 
september18.ppt
september18.pptseptember18.ppt
september18.ppt
 
Introduction to Graph Theory
Introduction to Graph TheoryIntroduction to Graph Theory
Introduction to Graph Theory
 
Lecture slides week14-15
Lecture slides week14-15Lecture slides week14-15
Lecture slides week14-15
 
Computing on Encrypted Data
Computing on Encrypted DataComputing on Encrypted Data
Computing on Encrypted Data
 
lecture1.ppt
lecture1.pptlecture1.ppt
lecture1.ppt
 
Intro
IntroIntro
Intro
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
lecture1.pdf
lecture1.pdflecture1.pdf
lecture1.pdf
 

Recently uploaded

CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
rpskprasana
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
mamunhossenbd75
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
gerogepatton
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
zubairahmad848137
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
Aditya Rajan Patra
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
University of Maribor
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
mamamaam477
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
NazakatAliKhoso2
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 

Recently uploaded (20)

CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
Engine Lubrication performance System.pdf
Engine Lubrication performance System.pdfEngine Lubrication performance System.pdf
Engine Lubrication performance System.pdf
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 

lecture1.ppt

  • 1. David Luebke 1 8/29/2022 CS 332: Algorithms Introduction Proof By Induction Asymptotic notation
  • 2. David Luebke 2 8/29/2022 The Course • Purpose: a rigorous introduction to the design and analysis of algorithms  Not a lab or programming course  Not a math course, either • Textbook: Introduction to Algorithms, Cormen, Leiserson, Rivest, Stein  The “Big White Book”  Second edition: now “Smaller Green Book”  An excellent reference you should own
  • 3. David Luebke 3 8/29/2022 The Course • Instructor: David Luebke  luebke@cs.virginia.edu  Office: Olsson 219  Office hours: 2-3 Monday, 10-11 Thursday • TA: Pavel Sorokin  Office hours and location TBA
  • 4. David Luebke 4 8/29/2022 The Course • Grading policy:  Homework: 30%  Exam 1: 15%  Exam 2: 15%  Final: 35%  Participation: 5%
  • 5. David Luebke 5 8/29/2022 The Course • Prerequisites:  CS 202 w/ grade of C- or better  CS 216 w/ grade of C- or better  CS 302 recommended but not required o Who has not taken CS 302?
  • 6. David Luebke 6 8/29/2022 The Course • Format  Three lectures/week  Homework most weeks o Problem sets o Maybe occasional programming assignments  Two tests + final exam
  • 7. David Luebke 7 8/29/2022 Review: Induction • Suppose  S(k) is true for fixed constant k o Often k = 0  S(n)  S(n+1) for all n >= k • Then S(n) is true for all n >= k
  • 8. David Luebke 8 8/29/2022 Proof By Induction • Claim:S(n) is true for all n >= k • Basis:  Show formula is true when n = k • Inductive hypothesis:  Assume formula is true for an arbitrary n • Step:  Show that formula is then true for n+1
  • 9. David Luebke 9 8/29/2022 Induction Example: Gaussian Closed Form • Prove 1 + 2 + 3 + … + n = n(n+1) / 2  Basis: o If n = 0, then 0 = 0(0+1) / 2  Inductive hypothesis: o Assume 1 + 2 + 3 + … + n = n(n+1) / 2  Step (show true for n+1): 1 + 2 + … + n + n+1 = (1 + 2 + …+ n) + (n+1) = n(n+1)/2 + n+1 = [n(n+1) + 2(n+1)]/2 = (n+1)(n+2)/2 = (n+1)(n+1 + 1) / 2
  • 10. David Luebke 10 8/29/2022 Induction Example: Geometric Closed Form • Prove a0 + a1 + … + an = (an+1 - 1)/(a - 1) for all a  1  Basis: show that a0 = (a0+1 - 1)/(a - 1) a0 = 1 = (a1 - 1)/(a - 1)  Inductive hypothesis: o Assume a0 + a1 + … + an = (an+1 - 1)/(a - 1)  Step (show true for n+1): a0 + a1 + … + an+1 = a0 + a1 + … + an + an+1 = (an+1 - 1)/(a - 1) + an+1 = (an+1+1 - 1)/(a - 1)
  • 11. David Luebke 11 8/29/2022 Induction • We’ve been using weak induction • Strong induction also holds  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
  • 12. David Luebke 12 8/29/2022 Asymptotic Performance • In this course, we care most about asymptotic performance  How does the algorithm behave as the problem size gets very large? o Running time o Memory/storage requirements o Bandwidth/power requirements/logic gates/etc.
  • 13. David Luebke 13 8/29/2022 Asymptotic Notation • By now you should have an intuitive feel for asymptotic (big-O) 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
  • 14. David Luebke 14 8/29/2022 Analysis of Algorithms • Analysis is performed with respect to a computational model • We will usually use a generic uniprocessor random-access machine (RAM)  All memory equally expensive to access  No concurrent operations  All reasonable instructions take unit time o Except, of course, function calls  Constant word size o Unless we are explicitly manipulating bits
  • 15. David Luebke 15 8/29/2022 Input Size • Time and space complexity  This is generally a function of the input size o E.g., sorting, multiplication  How we characterize input size depends: o Sorting: number of input items o Multiplication: total number of bits o Graph algorithms: number of nodes & edges o Etc
  • 16. David Luebke 16 8/29/2022 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 o y = m * x + b o c = 5 / 9 * (t - 32 ) o z = f(x) + g(y) • We can be more exact if need be
  • 17. David Luebke 17 8/29/2022 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”? o Random (equally likely) inputs o Real-life inputs
  • 18. David Luebke 18 8/29/2022 The End