Slide 1

Slide 1 text

cs2102: Discrete Mathematics Class 25: Counting David Evans, Mohammad Mahmoody

Slide 2

Slide 2 text

Plan Today: How to Count! (parts of Chapter 15) Thursday: Probability (parts of Chapters 17,18) Next Tuesday: Review Next Thursday: Final Exam

Slide 3

Slide 3 text

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.

Slide 4

Slide 4 text

Why Counting? • Estimating time/storage/cost of an algorithm • Estimating the “security”: how many bits does adversary have to “guess” ? • Basis for probability theory.

Slide 5

Slide 5 text

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.

Slide 6

Slide 6 text

Examples 1. How many subsets does have if = 20? 2. How many numbers of (at most) 20 bits? • Bijection between them:

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

Example: number of sequences • How many -sequences with elements in {1, … , } ?

Slide 9

Slide 9 text

• What if 1 and 2 can have intersection? • What if = 3? • Generalization: Inclusion-Exclusion (look it up in the book!)

Slide 10

Slide 10 text

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?

Slide 11

Slide 11 text

• 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

Slide 12

Slide 12 text

Example: counting permutations • A permutation of = {1 , … } is an (ordered) sequence 1 , … , such that every appears exactly once. • How many permutations are there?

Slide 13

Slide 13 text

More on “!” • 0! = 1 • Approximating !

Slide 14

Slide 14 text

• How many ways to select -sequences with elements chosen from 1, … , : – Repetition allowed: – Repetition not allowed? Role of Repetition (allowed or not?)

Slide 15

Slide 15 text

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”.

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

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, … , …