Download presentation
Presentation is loading. Please wait.
Published byGotthilf Brandt Modified over 6 years ago
1
Mathematics for Computer Science MIT 6.042J/18.062J
Combinatorics I Copyright © Radhika Nagpal, 2002. Prof. Albert Meyer & Dr. Radhika Nagpal
2
Counting 4-digit Strings with 7s
All strings minus strings with no 7s Count strings based on the first occurrence of 7 7xxx + o7xx + oo7x + ooo7 Count strings based on how many 7s are there strings with one 7 + strings with two 7s + strings with three 7s + strings with four 7s
3
Counting Techniques Bijections Sum Rule, Inclusion-Exclusion
Product Rule Pigeonhole Principle Trees Permutations
4
Counting Strings (again)
How many strings of length 3 can make with the alphabet A = {r,a,d} ?
5
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
6
Counting Rearrangements
How many strings of length 3 can I make by rearranging the letters rad?
7
Permutations (3) (2) (1) {r,a,d} {?,?} {?}
(3) (2) (1) {r,a,d} {?,?} {?} Number of strings, |S| = = 6
8
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}
9
Permutation Tree d rad rda ard adr dra dar a a d d r r a d r d r a a r
10
… … 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
11
Comparison rearrangement strings n n2 n! nn 1 1 1 1 5 25 120 3125
~ ~ ~ ~ scheme dies…..
12
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
13
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
14
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
15
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 = =
16
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
17
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}
18
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!
19
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
20
Graphs as Binary Strings
Maximum possible edges = n2 e1 e2 e3 …… en2 G ….. 1 G ……1 G
21
Graphs as Boolean Matrices
0 1 1 2 3 . n Any assignment of 1s and 0s is a possible graph
22
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
23
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!
24
In-class Problems
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.