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 Techniques Bijections Sum Rule, Inclusion-Exclusion
Product Rule Pigeonhole Principle Trees Permutations

3 Counting Strings How many strings of length 3 can make with the alphabet A = {r,a,d} ?

4 Counting Strings (3) (3) (3) {r,a,d} {r,a,d} {r,a,d}
(3) (3) (3) {r,a,d} {r,a,d} {r,a,d} Number of strings = = 27

5 Counting Rearrangements
How many strings of length 3 can I make by rearranging the letters rad?

6 Permutations (3) (2) (1) {r,a,d} {?,?} {?}
(3) (2) (1) {r,a,d} {?,?} {?} Number of strings, |S| = = 6

7 Permutations (3) (2) (1) {r,a,d} {?,?} {?} S = {rad, rda ard, adr
(3) (2) (1) {r,a,d} {?,?} {?} S = {rad, rda ard, adr dra, dar}

8 Permutation Tree d rad rda ard adr dra dar a a d d r r a d r d r a a r

9 … … Strings Tree r a d r r a a d d r r a a d d rrr rra rrd rar raa rad
rda rdd ….. drr dra drd dar daa dad ddr dda ddd a d r r a a d d r r a a d d

10 Comparison rearrangement strings n n2 n! nn 1 1 1 1 5 25 120 3125
~ ~ ~ ~ scheme dies…..

11 Important technique: Matching
Make a one-to-one 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

12 Counting Functions f B A
How many different possible functions are there from A to B? f b1 b2 b3 b4 b5 b6 a1 a2 a3 a4 a5 A B

13 Mapping: Functions as Strings
a1 a2 a3 a4 a5 A B b1 b1 b1 b1 b1 b1 b2 b3 b1 b4 …… string of length 5 from the alphabet {b1, b2…b6} f

14 Counting Functions A B (6) (6) (6) (6) (6)
a1 a2 a3 a4 a5 A B (6) (6) (6) (6) (6) Total number of possible functions = total number of possible strings = =

15 Counting Bijections f B A
How many different possible bijections are there from A to B? f a1 a2 a3 a4 a5 b1 b2 b3 b4 b5 A B

16 Counting Bijections A B Permutations of the letters {b1,b2,b3,b4,b5}
a1 a2 a3 a4 a5 A B b1 b2 b3 b4 b5 b5 b4 b3 b2 b1 …… Permutations of the letters {b1,b2,b3,b4,b5}

17 Counting Bijections A B (5) (4) (3) (2) (1)
a1 a2 a3 a4 a5 A B (5) (4) (3) (2) (1) Total number of possible functions = total number of possible permutations = = 5!

18 Counting Graphs v1 v1 v1 v2 v3 v2 v3 v2 v3
How many possible directed graphs are there on n nodes? v1 v1 v1 v2 v3 v2 v3 v2 v3

19 Graphs as Binary Strings
Maximum possible edges = n2 e1 e2 e3 …… en2 G ….. 1 G ……1 G

20 Graphs as Boolean Matrices
0 1 1 2 3 . n Any assignment of 1s and 0s is a possible graph

21 Proving that a Mapping is a Bijection
Prove that g: F S is a bijection Prove that all elements in F map to a unique elements of S Prove that all elements in S map to some F

22 Example: Graph Isomorphism
G1 and G2 are isomorphic if there is a bijection f from the nodes of G1 to the nodes of G2, that preserve the adjacency lists. Question: At most how many functions do I need to check to determine whether or not G1 and G2 are isomorphic? Answer: All possible bijections from the nodes of G1 to G2 = n!

23 In-class Problems


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

Similar presentations


Ads by Google