Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mathematics for Computer Science MIT 6.042J/18.062J

Similar presentations


Presentation on theme: "Mathematics for Computer Science MIT 6.042J/18.062J"— Presentation transcript:

1 Mathematics for Computer Science MIT 6.042J/18.062J
Combinatorics I Copyright © Radhika Nagpal, 2002. Prof. Albert Meyer & Dr. Radhika Nagpal

2 Counting in Algorithms
How many different ways can 3 colors be assigned to an n-node graph? How many different mappings need to be checked to see if two arbitrary n-node graphs are isomorphic? How many stable pairings are there between n girls and n boys?

3 Counting in Algorithms
What is the minimum number of binary comparisons needed to sort n numbers? i.e. what is the best any algorithm could possibly do?

4 Counting in Games How many different initial positions exist for a rubix cube? How many different chess boards can exist after 3 moves? After 6 moves? How many weighings do you need to find one counterfeit coin amongst 12 coins?

5 Counting in Probability
Probability of a special event occurring # of special events # total events (simplified view) What is the probability of getting two jacks in a five card draw poker game? =

6 Counting Techniques Bijections Sum Rule, Inclusion-Exclusion
Product Rule Pigeonhole Principle Trees Permutations

7 Counting Techniques Bijections Sum Rule, Inclusion-Exclusion
Product Rule Pigeonhole Principle Trees Permutations

8 Bijections If f is a bijection from A to B, then |A| = |B| A B f

9 If sets A and B are disjoint, then
Sum Rule If sets A and B are disjoint, then |A U B| = |A| + |B| A B

10 If sets A and B are disjoint, then
Sum Rule If sets A and B are disjoint, then |A U B| = |A| + |B| What if A and B are not disjoint? A B

11 Inclusion-Exclusion (2 Sets)
For two arbitrary sets A and B A B

12 Inclusion-Exclusion (2 Sets)
Also, |A U B| < |A| + |B| A B

13 Inclusion-Exclusion (3 Sets)
A B C

14 Product Rule If |A| = m and |B| = n, then |A x B| = mn

15 Product Rule If |A| = m and |B| = n, then |A x B| = mn
A = {a, b, c}, B = {1, 2, 3}

16 Product Rule If |A| = m and |B| = n, then |A x B| = mn
A = {a, b, c}, B = {1, 2, 3} A x B = {(a,1) (a,2) (a,3) (b,1) (b,2) (b,3) (c,1) (c,2) (c,3)}

17 Product Rule If |A| = m and |B| = n, then |A x B| = mn
A = {a, b, c}, B = {1, 2, 3} A x B = {(a,1) (a,2) (a,3) (b,1) (b,2) (b,3) (c,1) (c,2) (c,3)} So |A x B| = 9

18 Product Rule: Counting Strings
The number of 4-bit strings from the alphabet A = {0,1} = |A x A x A x A| = =

19 Product Rule: Tree 1111 1110 1101 1100 1011 0000 1 1

20 Product Rule: Counting Strings
The number of n-bit strings from the alphabet A of size m

21 Example Given a set A, how many subsets are there? i.e. |P(A)| ?
A = {a, b, c} P(A) = {{} {a} {b} {c} {a,b} {b,c} {c,a} {a,b,c}}

22 Bijection: P(A) and Binary Strings
A = {a1 a2 a3 a4 a5……an} Binary String = Subset of A = {a1, a3, a5}

23 Bijection: P(A) and Binary Strings
A = {a1 a2 a3 a4 a5……an} Binary String = Subset of A = {a1, a3, a5} Exact correspondence Number of n-bit binary strings = If |A| =n, then P(A) =

24 Pigeonhole Principle If you have n pigeons and m holes and n > m, then at least one hole must have two pigeons

25 Example: Birthdays If 366 people, in the room then two must have the same birthday (day/month). If 731 people, then 3 must have same birthday…

26 In-class Problems

27 Summary Sum rule Inclusion Exclusion Product Rule Pigeonhole Principle
If |A| = m and |B| = n, then |A x B| = mn Pigeonhole Principle If n pigeons, m holes, n>m, then must be at least 2 in some hole - If sets A and B are disjoint, then |A U B| = |A| + |B|

28

29 Counting Strings with 7s
False Argument Counted numbers with multiple 7s many times

30 A Correct Argument All 4-digit numbers with at least one 7
= all possible 4-digit numbers, minus 4-digit numbers with no 7s. Both of these are easy to count

31 An Alternate Counting? Is this argument correct?

32 Algebra or Calculator Are these two the same?

33 How do you know if it is correct?
Many ways of counting the same thing How do you know you got it right? Algebra, calculator Prove it!

34 Proving Correctness Prove that you counting correctly
Prove that you counted everything Prove that you didn’t count anything twice

35 Another Pigeonhole Problem
Say that we have 6 people, such that every pair of people are either friends or strangers, then there is always a set of 3 friends or 3 strangers

36 Restated as a Graph problem
In a 6-node complete graph, where every edge is colored red or blue, there always exists either a red triangle or a blue triangle

37 Not always so easy…. How many people do you need before you are guaranteed to have a set of six that know each other? Paul Erdos’s answer: If aliens required you answer this in a year, throw in the towel and strike preemptively…. Ramsey numbers R(3,3)=6 R(6,6)=??

38 Next lecture Trees, Permutations, r-Permutations Importance of mapping
Functions and strings How many possible functions, How many possible bijections?

39 Important technique: Matching
Make a mapping between a given problem and a set of known cardinality (or at least one we know how to count…) Functions->binary strings Lists->trees Graphs, Relations->matrices Strings, polynomials->balls and bins


Download ppt "Mathematics for Computer Science MIT 6.042J/18.062J"

Similar presentations


Ads by Google