Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Class 25

Class 25

Counting 1

Mohammad Mahmoody

November 28, 2017
Tweet

More Decks by Mohammad Mahmoody

Other Decks in Education

Transcript

  1. Plan Today: How to Count! (parts of Chapter 15) Thursday:

    Probability (parts of Chapters 17,18) Next Tuesday: Review Next Thursday: Final Exam
  2. Examples 1. How many subsets does have if = 20?

    2. How many numbers of (at most) 20 bits (in base 2) ? 3. How many (at most) 16-bit numbers with exactly 4 ones? 4. How many ways to choose 12 doughnuts from 5 varieties.
  3. Why Counting? • Estimating time/storage/cost of an algorithm • Estimating

    the “security”: how many bits does adversary have to “guess” ? • Basis for probability theory.
  4. Recall Finite Cardinality (class 9) • Many counting problems can

    be cast as: “how many elements are in set ?” The cardinality of the set = ∈ ℕ ∧ < } is . If there is a bijection between and then has the same cardinality.
  5. Examples 1. How many subsets does have if = 20?

    2. How many numbers of (at most) 20 bits? • Bijection between them:
  6. • What if 1 and 2 can have intersection? •

    What if = 3? • Generalization: Inclusion-Exclusion (look it up in the book!)
  7. Example: counting passwords • Suppose valid password: 1. Sequence of

    6 to 8 symbols. 2. First symbol: a letter (lowercase or uppercase). 3. Remaining symbols: must be either letters or digits. • How many different passwords are possible?
  8. • is a set containing length- sequences. If – 1

    possibilities for 1st entry – For each 1st entry: 2 possibilities for 2nd entry – … – For each ( − 1)st entry: possibilities for th entry • Then = 1 ⋅ 2 … ⋅ Generalized Product Rule
  9. Example: counting permutations • A permutation of = {1 ,

    … } is an (ordered) sequence 1 , … , such that every appears exactly once. • How many permutations are there?
  10. • How many ways to select -sequences with elements chosen

    from 1, … , : – Repetition allowed: – Repetition not allowed? Role of Repetition (allowed or not?)
  11. Counting when order does not matter • How many ways

    to select a -subset of 1, … , ? • Namely: = { ∣ ⊆ , = } what is ? • This number is denoted as : read “n choose k”.
  12. Counting when order does not matter • How many ways

    to select a -subset of 1, … , ? • Namely: = { ∣ ⊆ , = } what is ? • Idea: define to contain -sequences using 1, … , …