SlideShare a Scribd company logo
Class 19: Analyzing Algorithms




                    cs1120 Fall 2011
                    David Evans
                    5 October 2011
Plan
Asymptotic Operators Recap
Analyzing bigger
How Bletchley Park Really Broke Lorenz
  (maybe not until Friday)


           Assistant Coaches’ Review Sessions for Exam 1:
               Tuesday (tomorrow), 6:30pm, Rice 442
                   Wednesday, 7:30pm, Rice 442

                                                            2
A   XOR Machine             B




                                TRUE




                                  FALSE



                                TRUE



                  Design by Alex Shin

                                          3
XOR Machine




                            Wine
                            Wine
                            Float
                            Wine
                            Float




NOT from book     Design by Anthony Teate

                                            4
XOR Machine



                            Wine
                            Wine
                            Float
                            Wine
                            Float
                            Wine
                            Float




NOT from book     Design by Anthony Teate

                                            5
Measuring Cost
Machines vary, so we want to understand how
 the cost to execute a procedure scales with
 the size of the input
We use the asymptotic operators to abstract
 away all the details




                                               6
Recap
Big-O: functions that grow no faster than f



Omega ( ): functions that grow no slower than f



Theta ( ): functions that grow as fast as f


                                                  7
Example
Prove: 73n2 + n   (n2)




                         8
Real CSists




              9
Proofs are Not Scary!
Theorem: There exists a polygon with four sides.

Proof:




                          What kind of proof is this?
Proof by Construction
We can prove a “there exists an X with property
 Y” theorem, by showing an X that has
 property Y
O(f) means “there are positive constants c and
 n0 such that g(n) cf(n) for all n n0

So, to prove g is in O(f) we need to find c and n0
  and show that g(n) cf(n) for all n n0
Dis-Proof by Construction
To prove g is not in O(f):
O(f) means: there are positive constants c and
  n0 such that g(n) cf(n) for all n n0

So, to prove g is not in O(f) we need to find a
  way given any c and n0, to find an n n0 such
  that g(n) > cf(n).
Example
Prove: 73n2 + n   (n2)




                         13
Algorithm Analysis
What is the asymptotic running time of the
Scheme procedure below:

    (define (bigger a b)
      (if (> a b) a b))




                                             14
Algorithm Analysis
What is the asymptotic running time of (> a b):

  (define (bigger a b)
    (if (> a b) a b))




                                                  15
What are we really measuring?
Input size: number of tape squares it takes to
  write down the input
Running time: number of steps it takes before
  TM enters a final state
Input size for (bigger a b) = n
  Number of tape squares to represent input (not its
   magnitude)

                           Why doesn’t the alphabet size matter?


                                                                   16
17
Next Class
What if the input is binary instead of unary?

       a>b# 0# if a > b, 1# if a b
       where a, b are the numbers a, b
         represented in binary




                                                18

More Related Content

PPTX
Stove assembly Prakti V1
PPTX
Alternate Cryptocurrencies
PPTX
Why are these buildings on fire?
PPTX
Lecture 2: Language
PPTX
Script
PPTX
Class 7: Programming with Lists
PPTX
Cryptography
PPTX
Introduction to Cryptography
Stove assembly Prakti V1
Alternate Cryptocurrencies
Why are these buildings on fire?
Lecture 2: Language
Script
Class 7: Programming with Lists
Cryptography
Introduction to Cryptography

Viewers also liked (10)

PPTX
What the &~#@<!? (Memory Management in Rust)
PPTX
Scheduling
PPTX
Microkernels and Beyond
PPTX
Mining
PPTX
Mutual Exclusion
PPTX
Class 1: What is Money?
PPTX
What the &~#@<!? (Pointers in Rust)
PPTX
Storage
PPTX
First Ride on Rust
PPTX
Class 36: Halting Problem
What the &~#@<!? (Memory Management in Rust)
Scheduling
Microkernels and Beyond
Mining
Mutual Exclusion
Class 1: What is Money?
What the &~#@<!? (Pointers in Rust)
Storage
First Ride on Rust
Class 36: Halting Problem
Ad

More from David Evans (20)

PPTX
Cryptocurrency Jeopardy!
PPTX
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
PPTX
Hidden Services, Zero Knowledge
PPTX
Anonymity in Bitcoin
PPTX
Midterm Confirmations
PPTX
Scripting Transactions
PPTX
How to Live in Paradise
PPTX
Bitcoin Script
PPTX
Mining Economics
PPTX
The Blockchain
PPTX
Becoming More Paranoid
PPTX
Asymmetric Key Signatures
PPTX
Multi-Party Computation for the Masses
PPTX
Proof of Reserve
PPTX
Silk Road
PPTX
Blooming Sidechains!
PPTX
Useful Proofs of Work, Permacoin
PPTX
Selfish Mining
PPTX
Quiz 2: Bitcoin Protocol, Mining, Supsersizing
PPTX
Mostly About Superfish
Cryptocurrency Jeopardy!
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Hidden Services, Zero Knowledge
Anonymity in Bitcoin
Midterm Confirmations
Scripting Transactions
How to Live in Paradise
Bitcoin Script
Mining Economics
The Blockchain
Becoming More Paranoid
Asymmetric Key Signatures
Multi-Party Computation for the Masses
Proof of Reserve
Silk Road
Blooming Sidechains!
Useful Proofs of Work, Permacoin
Selfish Mining
Quiz 2: Bitcoin Protocol, Mining, Supsersizing
Mostly About Superfish
Ad

Recently uploaded (20)

PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
cuic standard and advanced reporting.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Getting Started with Data Integration: FME Form 101
PDF
Approach and Philosophy of On baking technology
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Spectral efficient network and resource selection model in 5G networks
cuic standard and advanced reporting.pdf
Machine learning based COVID-19 study performance prediction
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Getting Started with Data Integration: FME Form 101
Approach and Philosophy of On baking technology
Dropbox Q2 2025 Financial Results & Investor Presentation
NewMind AI Weekly Chronicles - August'25-Week II
Mobile App Security Testing_ A Comprehensive Guide.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Building Integrated photovoltaic BIPV_UPV.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
20250228 LYD VKU AI Blended-Learning.pptx
MYSQL Presentation for SQL database connectivity
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Group 1 Presentation -Planning and Decision Making .pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

Class 19: Analyzing Algorithms

  • 1. Class 19: Analyzing Algorithms cs1120 Fall 2011 David Evans 5 October 2011
  • 2. Plan Asymptotic Operators Recap Analyzing bigger How Bletchley Park Really Broke Lorenz (maybe not until Friday) Assistant Coaches’ Review Sessions for Exam 1: Tuesday (tomorrow), 6:30pm, Rice 442 Wednesday, 7:30pm, Rice 442 2
  • 3. A XOR Machine B TRUE FALSE TRUE Design by Alex Shin 3
  • 4. XOR Machine Wine Wine Float Wine Float NOT from book Design by Anthony Teate 4
  • 5. XOR Machine Wine Wine Float Wine Float Wine Float NOT from book Design by Anthony Teate 5
  • 6. Measuring Cost Machines vary, so we want to understand how the cost to execute a procedure scales with the size of the input We use the asymptotic operators to abstract away all the details 6
  • 7. Recap Big-O: functions that grow no faster than f Omega ( ): functions that grow no slower than f Theta ( ): functions that grow as fast as f 7
  • 10. Proofs are Not Scary! Theorem: There exists a polygon with four sides. Proof: What kind of proof is this?
  • 11. Proof by Construction We can prove a “there exists an X with property Y” theorem, by showing an X that has property Y O(f) means “there are positive constants c and n0 such that g(n) cf(n) for all n n0 So, to prove g is in O(f) we need to find c and n0 and show that g(n) cf(n) for all n n0
  • 12. Dis-Proof by Construction To prove g is not in O(f): O(f) means: there are positive constants c and n0 such that g(n) cf(n) for all n n0 So, to prove g is not in O(f) we need to find a way given any c and n0, to find an n n0 such that g(n) > cf(n).
  • 14. Algorithm Analysis What is the asymptotic running time of the Scheme procedure below: (define (bigger a b) (if (> a b) a b)) 14
  • 15. Algorithm Analysis What is the asymptotic running time of (> a b): (define (bigger a b) (if (> a b) a b)) 15
  • 16. What are we really measuring? Input size: number of tape squares it takes to write down the input Running time: number of steps it takes before TM enters a final state Input size for (bigger a b) = n Number of tape squares to represent input (not its magnitude) Why doesn’t the alphabet size matter? 16
  • 17. 17
  • 18. Next Class What if the input is binary instead of unary? a>b# 0# if a > b, 1# if a b where a, b are the numbers a, b represented in binary 18