Class 19: Analyzing Algorithms

499 views

Published on

XOR Machines
Proof by Construction
Algorithm Analysis
Turing Machine

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
499
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Class 19: Analyzing Algorithms

  1. 1. Class 19: Analyzing Algorithms cs1120 Fall 2011 David Evans 5 October 2011
  2. 2. PlanAsymptotic Operators RecapAnalyzing biggerHow 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. 3. A XOR Machine B TRUE FALSE TRUE Design by Alex Shin 3
  4. 4. XOR Machine Wine Wine Float Wine FloatNOT from book Design by Anthony Teate 4
  5. 5. XOR Machine Wine Wine Float Wine Float Wine FloatNOT from book Design by Anthony Teate 5
  6. 6. Measuring CostMachines vary, so we want to understand how the cost to execute a procedure scales with the size of the inputWe use the asymptotic operators to abstract away all the details 6
  7. 7. RecapBig-O: functions that grow no faster than fOmega ( ): functions that grow no slower than fTheta ( ): functions that grow as fast as f 7
  8. 8. ExampleProve: 73n2 + n (n2) 8
  9. 9. Real CSists 9
  10. 10. Proofs are Not Scary!Theorem: There exists a polygon with four sides.Proof: What kind of proof is this?
  11. 11. Proof by ConstructionWe can prove a “there exists an X with property Y” theorem, by showing an X that has property YO(f) means “there are positive constants c and n0 such that g(n) cf(n) for all n n0So, 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. 12. Dis-Proof by ConstructionTo 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 n0So, 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).
  13. 13. ExampleProve: 73n2 + n (n2) 13
  14. 14. Algorithm AnalysisWhat is the asymptotic running time of theScheme procedure below: (define (bigger a b) (if (> a b) a b)) 14
  15. 15. Algorithm AnalysisWhat is the asymptotic running time of (> a b): (define (bigger a b) (if (> a b) a b)) 15
  16. 16. What are we really measuring?Input size: number of tape squares it takes to write down the inputRunning time: number of steps it takes before TM enters a final stateInput 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. 17
  18. 18. Next ClassWhat 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

×