Download presentation

Presentation is loading. Please wait.

Published byAubrie Overfield Modified over 3 years ago

1
Counting

2
Counting = Determining the number of elements of a finite set

3
Counting Rules Product Rule: If there are n 1 choices for the first item and n 2 choices for the second item, then there are n 1 n 2 choices for the two items Sum Rule: If there are n 1 choices of an element from S 1 and n 2 choices of an element from S 2 and S 1 S 2 is empty, then there are n 1 + n 2 choices of an element from S 1 S 2

4
Counting Examples License numbers have the form LLL DDD. How many different license numbers are available? There are 38 students in a class, and 38 chairs. How many different seating arrangements are there if everyone shows up? How many different predicates are there on = {a,…,z}?

5
Important Cases of the Product Rule Cartesian product –|A 1 A 2 … A n | = |A 1 ||A 2 | |A n | Subsets of a set S –|P(S)|= 2 |S| Strings of length n over –| n | = | | n

6
Counting Functions Suppose |S| = n, |T| = m How many functions from S to T? How many one-to-one functions from S to T?

7
More Complicated Counting Examples BASIC variable names –Variables can be one or two characters long The first character must be a letter The second character can be a letter or a digit The keywords “TO”, “IF”, and “DO” are excluded

8
Counting Passwords Passwords must be 4 to 6 characters long, and must contain at least one letter and at least one digit. (Case insensitive, no special characters.)

9
Inclusion-Exclusion Principle How many binary strings of length 9 start with 00 or end with 11? |A 1 A 2 | = |A 1 | + |A 2 | - |A 1 A 2 |

10
Inclusion-Exclusion A class has of 40 students has 20 CS majors and 15 math majors. 5 of these students are dual majors. How many students in the class are neither math nor CS majors?

11
Generalizing Inclusion-Exclusion General: + Singles – Pairs + Triples – Quads +...

12
Pigeonhole Principle If k is a positive integer and k+1 or more objects are placed into k boxes, then at least one box has two or more objects If N objects are placed into k boxes, then there is at least one box containing at least N/k objects

13
PHP Applications Prove that if a city has at least 10 million phone subscribers it needs more than one area code. (Phone numbers of the form XXX-XXXX.) Prove that if you have 800 people, at least three share a common birthday.

14
Clever PHP Applications Every sequence of n 2 + 1 distinct numbers contains a subsequence of length n+1 that is either strictly increasing or strictly decreasing. 4, 22, 8, 15, 19, 11, 2, 1, 9, 20, 10, 7, 16, 3, 6, 5, 14

15
Proof Let a 1,... a m be a sequence of n 2 +1 distinct numbers Let i k be the length of the longest increasing sequence starting at a k Let d k be the length of the longest decreasing sequence starting at a k Suppose i k n and d k n for all k There are n 2 possible values of (i k, d k ) So there must be k and j, k < j, with i k = i j and d k = d j This is a contradiction: –If a k i j (start at a k and continue with the longest increasing sequence starting at a l )

16
Permutations vs. Combinations How many ways are there of selecting 1 st, 2 nd, and 3 rd place from a group of 10 sprinters? How many ways are there of selecting the top three finishers from a group of 10 sprinters?

17
r-Permutations An r-permutation is an ordered selection of r elements from a set P(n, r), number of r-permutations of an n-element set:

18
r-Combinations An r-combination is an unordered selection of r elements from a set (or just a subset of size r) C(r, n), number of r-permutations of an n-element set:

19
How Many? Binary strings of length 10 with 3 0’s Binary strings of length 10 with 7 1’s How many different ways of assigning 38 students to the 5 seats in the front of the class How many different ways of assigning 38 students to a table that seats 5 students

20
Prove C(n, r) = C(n, n-r) [Proof 1] Proof by formula

21
Prove C(n, r) = C(n, n-r) [Proof 2] Combinatorial proof –Set S with n elements –Every subset A of S with r elements corresponds to a subset of S with n – r elements (the complement of A)

22
Counting Paths How many paths are there of length n+m-2 from the upper left corner to the lower right corner of an n m grid?

23
Binomial Theorem

24
Binomial Coefficient Identities from the Binomial Theorem

25
Pascal’s Identity and Triangle

26
Recap Permutations Combinations

27
How Many? Let s 1 be a string of length n over Let s 2 be a string of length m over Assuming and are distinct, how many interleavings are there of s 1 and s 2 ?

28
Permutations with Repetition

29
Combinations with Repetition How many different ways are there of selecting 5 letters from {A, B, C} with repetition?

30
How many non-decreasing sequences of {1,2,3} of length 5 are there?

31
How many different ways are there of adding 3 non-negative integers to get 5 ? 1 + 2 + 2 | | 2 + 0 + 3 | | 0 + 1 + 4 3 + 1 + 1 5 + 0 + 0

32
C(n+r-1,n-1) r-combinations of an n element set with repetition

33
Permutations of Indistinguishable Objects How many different strings can be made from reordering the letters ABCDEFGH? How many different strings can be made from reordering the letters AAAABBBB? How many different strings can be made from reordering the letters GOOOOGLE?

Similar presentations

OK

Basic Counting. This Lecture We will study some basic rules for counting. Sum rule, product rule, generalized product rule Permutations, combinations.

Basic Counting. This Lecture We will study some basic rules for counting. Sum rule, product rule, generalized product rule Permutations, combinations.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on diode Ppt on historical places in pune india Ppt on combination of resistances to change Ppt on indian air force Ppt on railway reservation system project Ppt on money and credit Ppt on global warming for class 5 Ppt on economic order quantity assumptions Ppt on bond length Ppt on cost ledger accounting