big
play

big o o Counting counting is hard with only 10 fingers How many - PDF document

312 washington.edu http courses.es Applications AI in Inference under uncertainty statistics modeled using probability speech recognition object recognition Ivision control navigation robot machine learning problem any simulation


  1. 312 washington.edu http courses.es Applications AI in Inference under uncertainty statistics modeled using probability speech recognition object recognition Ivision control navigation robot machine learning problem any simulation cryptography systems data big o o

  2. Counting

  3. counting is hard with only 10 fingers How many ways to do X ? X = “Choose an integer between one and ten.” X = “Walk from 1 st and Spring to 5 th and Pine.” Pine Pike Union Spring 1 st 2 nd 3 rd 4 th 5 th

  4. counting is hard with only 10 fingers How many ways to do X ? X = “Choose an integer between one and ten.” X = “Walk from 1 st and Spring to 5 th and Pine.” Pine Pike Counting is hard when numbers are large or constraints are complex. We need a systematic approach. Union Spring 1 st 2 nd 3 rd 4 th 5 th

  5. the basic principle of counting (product rule) If there are m outcomes from some event A , followed sequentially by n outcomes from some event B , then there are … 5 meats m x n outcomes overall. 4 cheeses 2 bread 3 condiments 5 4 a 2 3 A, A, m=4 120 B, B, n= n=2 4 x 2 2 = 8 8 outcome mes Generalizes to more events.

  6. examples How many n-bit numbers are there? 2 • 2 • ... • 2 = 2 n How many subsets of a set of size n are there? { 1 , 2 , 3 , …, n} Set contains 1 or doesn’t contain 1 . Set contains 2 or doesn’t contain 2 . Set contains 3 or doesn’t contain 3… 2 • 2 • ... • 2 = 2 n

  7. examples How many 4-character passwords are there if each character must be one of a, b, c, …, z, 0 , 1 , 2 , …, 9 ? 36 • 36 • 36 • 36 = 1,679,616 ≈ 1.7 million Same question, but now characters cannot be repeated… 36 • 35 • 34 • 33 = 1,413,720 ≈ 1.4 million

  8. permutations How many arrangements of the letters {a,b,c} are possible (using each once, no repeat, order matters)? a b c b a c c a b a c b b c a c b a More generally, how many arrangements of n distinct items are possible? n • (n-1) • (n-1) • ... • 1 = n! (n factorial) 2

  9. permutations Q. How many permutations of PEALS are there? 5 Q. How many of APPLE ? Appa L E It AP 1 P 2 LE eh AP 2 P 1 LE www.rmnsrjvyu.pt aLPzEP A Q. How many of APPPLLE ? 7 ordered arrangements u u PaB Pi p 3 2 3 2

  10. permutations Q. How many permutations of PEALS are there? 5! 5! = 120 120 Q. How many of APPLE ? AP 1 P 2 LE 5!/ 5!/2! 2! = 60 60 AP 2 P 1 LE Q. How many of APPPLLE ?

  11. combinations Your dark elf avatar can carry three objects chosen from: How many ways can he/she be equipped? 5 4.3 3T B 5 E 04h E

  12. combinations Your dark elf avatar can carry three objects chosen from: How many ways can he/she be equipped?

  13. combinations Combinat Co ations: Number of ways to choose r things from n things I 2 h h h l f rt E ordered sequences Pronounced “n choose r” aka “binomial coefficients” of r out of h dis t Inc lets E.g., To get of hardened sets of r out of n distinct elts Many identities: divide by r Ma

  14. counting paths How many ways to walk from 1 st and Spring to 5 th and Pine only going North and East? Pine E N N E N EE Pike LY Q2 I3 Union choose 7 G S positions 3 Spring for north steps 1 st 2 nd 3 rd 4 th 5 th A: Changing the visualization often helps. Instead of tracing paths on the grid above, list choices. You walk 7 blocks; at ✓ 7 ◆ each intersection choose N or E; must choose N exactly 3 times. = 35 3

  15. counting paths How many ways to walk from 1 st and Spring to 5 th and Pine only going North and East, if I want to stop at Starbucks on the way? Pine Pike Union Spring 1 st 2 nd 3 rd 4 th 5 th

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend