Mathematics for Computer Science MIT 6.042J/18.062J

Slides:



Advertisements
Similar presentations
Counting. Counting in Algorithms How many comparisons are needed to sort n numbers? How many steps to compute the GCD of two numbers ? How many steps.
Advertisements

Copyright © 2002 by Radhika Nagpal and Charles E. Leiserson. All rights reserved. October 30, L9-2.1 Mathematics for Computer Science MIT 6.042J/18.062J.
Counting. Counting = Determining the number of elements of a finite set.
Lecture 4 4.1,4.2 Counting. 4.1 Counting Two Important Principles: Product Rule and Sum Rule. Product Rule: Assume we need to perform procedure 1 AND.
22C:19 Discrete Structures Trees Spring 2014 Sukumar Ghosh.
Section 4.1: The Basics of Counting As we have seen, one way to count the number of objects in a finite set S is to produce a one-to-one correspondence.
More Counting Lecture 16: Nov 9 A B …… f. Counting Rule: Bijection If f is a bijection from A to B, then |A| = |B| A B …… f.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
Basic Counting Lecture 12: Oct 28. This Lecture We will study some basic rules for counting. Sum rule, product rule, generalized product rule Permutations,
Basic Counting. This Lecture We will study some basic rules for counting. Sum rule, product rule, generalized product rule Permutations, combinations.
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
September1999 CMSC 203 / 0201 Fall 2002 Week #8 – 14/16 October 2002 Prof. Marie desJardins.
1 CSC 321: Data Structures Fall 2013 Counting and problem solving  mappings, bijection rule  sequences, product rule, sum rule  generalized product.
CSC-2259 Discrete Structures Konstantin Busch Louisiana State University K. Busch - LSU.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
Discrete Mathematics for Computer Science. + + ( ) + ( ) = ? Counting II: Recurring Problems and Correspondences Chapter 9 slides 1-54.
Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7.1 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesBoolean Algebra.
Counting Techniques. L172 Agenda Section 4.1: Counting Basics Sum Rule Product Rule Inclusion-Exclusion.
Counting II: Recurring Problems And Correspondences Great Theoretical Ideas In Computer Science John LaffertyCS Fall 2005 Lecture 7Sept 20, 2005Carnegie.
CSCI 2670 Introduction to Theory of Computing November 17, 2005.
Counting II: Recurring Problems And Correspondences Great Theoretical Ideas In Computer Science V. AdamchikCS Spring 2006 Lecture 6Feb 2, 2005Carnegie.
Introduction Suppose that a password on a computer system consists of 6, 7, or 8 characters. Each of these characters must be a digit or a letter of the.
Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesBoolean Algebra.
CS 104: Discrete Mathematics
Introductory Lecture. What is Discrete Mathematics? Discrete mathematics is the part of mathematics devoted to the study of discrete (as opposed to continuous)
Section The Product Rule  Example: How many different license plates can be made if each plate contains a sequence of three uppercase English letters.
WHAT IS BINARY? Binary is a number system that only uses two digits: 1 and 0. Any information that processed by a computer it is put into sequence of.
Review: Discrete Mathematics and Its Applications
CSC 321: Data Structures Fall 2015 Counting and problem solving
The Pigeonhole Principle
Introduction to Combinatorics
CSC 321: Data Structures Fall 2016 Counting and proofs
Permutations and Combinations
CS 2210 Discrete Structures Counting
CS100: Discrete structures
Mathematics for Computer Science MIT 6.042J/18.062J
Mathematics for Computer Science MIT 6.042J/18.062J
Set, Combinatorics, Probability & Number Theory
ICS 353: Design and Analysis of Algorithms
Math/CSE 1019: Discrete Mathematics for Computer Science Fall 2011
Asymptotics & Stirling’s Approximation
Mathematics for Computer Science MIT 6.042J/18.062J
Basic Counting.
and Structural Induction II
Combinatorics.
Mathematics for Computer Science MIT 6.042J/18.062J
and Structural Induction II
DISCRETE COMPUTATIONAL STRUCTURES
Review: Discrete Mathematics and Its Applications
Chapter 11 Limitations of Algorithm Power
and Structural Induction
and Structural Induction II
Counting Discrete Mathematics.
Basic Counting Lecture 9: Nov 5, 6.
Mathematics for Computer Science MIT 6.042J/18.062J
and Structural Induction
and Structural Induction
Representations of Integers
Asymptotics & Stirling’s Approximation
Mathematics for Computer Science MIT 6.042J/18.062J
Miniconference on the Mathematics of Computation
Truth and Proof Math vs. Reality Propositions & Predicates
Copyright © Zeph Grunschlag,
Copyright © Zeph Grunschlag,
Discrete Mathematics for Computer Science
and Structural Induction
Chapter 3. Sets & Combinatorics
Presentation transcript:

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

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

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

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

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 = 3.3.3 = 27

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

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

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}

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

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

Comparison rearrangement strings n n2 n! nn 1 5 10 20 100 1000

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

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

Mapping: Functions as Strings a1 a2 a3 a4 a5 A B

Mapping: Functions as Strings a1 a2 a3 a4 a5 A B b1 b1 b1 b1 b1 b1 b2 b3 b1 b4 ……

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

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 = 6.6.6.6.6 =

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

Counting Bijections A B a1 a2 a3 a4 a5 b1 b2 b3 b4 b5 b5 b4 b3 b2 b1 ……

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}

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.4.3.2.1 = 5!

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

Graphs as Binary Strings Maximum possible edges = e1 e2 e3 ………e G1 1 0 1 0 ….. 1 G2 0 1 1 0……1 G3 ..

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

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

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.

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?

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!

In-class Problems