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

CSC-2259 Discrete Structures
3.3 The Characteristic function of the set  function from universal set to {0,1}  Definition 3.6: Let U be the universal set, and let A  U. The characteristic.
Copyright © Zeph Grunschlag, Counting Techniques Zeph Grunschlag.
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
Functions A B f( ) =. This Lecture We will define a function formally, and then in the next lecture we will use this concept in counting. We will also.
Sets, Combinatorics, Probability, and Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProbability.
Sets, Combinatorics, Probability, and Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProbability.
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
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
Topics to be covered: Produce all combinations and permutations of sets. Calculate the number of combinations and permutations of sets of m items taken.
1 Relations and Functions Chapter 5 1 to many 1 to 1 many to many.
Binomial Coefficients, Inclusion-exclusion principle
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
September1999 CMSC 203 / 0201 Fall 2002 Week #8 – 14/16 October 2002 Prof. Marie desJardins.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
3. Counting Permutations Combinations Pigeonhole principle Elements of Probability Recurrence Relations.
ICS 253: Discrete Structures I Counting and Applications King Fahd University of Petroleum & Minerals Information & Computer Science Department.
1 CSC 321: Data Structures Fall 2013 Counting and problem solving  mappings, bijection rule  sequences, product rule, sum rule  generalized product.
The Pigeonhole Principle. The pigeonhole principle Suppose a flock of pigeons fly into a set of pigeonholes to roost If there are more pigeons than pigeonholes,
Main Menu Main Menu (Click on the topics below) Combinatorics Introduction Equally likely Probability Formula Counting elements of a list Counting elements.
1 Melikyan/DM/Fall09 Discrete Mathematics Ch. 7 Functions Instructor: Hayk Melikyan Today we will review sections 7.3, 7.4 and 7.5.
1 Finding a decomposition of a graph T into isomorphic copies of a graph G is a classical problem in Combinatorics. The G-decomposition of T is balanced.
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.
CS 104: Discrete Mathematics
Operations on Sets Union of Sets Intersection of Sets
Section 5.1 and 5.2 Probability
Adding Probabilities 12-5
MAT 142 Lecture Video Series
ICS 253: Discrete Structures I
CSC 321: Data Structures Fall 2015 Counting and problem solving
ICS 253: Discrete Structures I
Chapter 7: Counting Principles
Copyright © Zeph Grunschlag,
The Pigeonhole Principle
Introduction to Combinatorics
Discrete Structures for Computer Science
Section 16 Inclusion/Exclusion
COCS DISCRETE STRUCTURES
CSC 321: Data Structures Fall 2016 Counting and proofs
Copyright © Zeph Grunschlag,
Is There Something to CS Theory?
CS100: Discrete structures
Mathematics for Computer Science MIT 6.042J/18.062J
Introduction Dr. X. Zhang, Fordham Univ. 1.
Set, Combinatorics, Probability & Number Theory
Set, Combinatorics, Probability & Number Theory
Counting I: Bijection and Choice Trees
Probability Models Section 6.2.
Math/CSE 1019: Discrete Mathematics for Computer Science Fall 2011
Mathematics for Computer Science MIT 6.042J/18.062J
Mathematics for Computer Science MIT 6.042J/18.062J
Basic Counting.
Combinatorics.
Mathematics for Computer Science MIT 6.042J/18.062J
CSC 321: Data Structures Fall 2018 Counting and proofs
Counting techniques Basic Counting Principles, Pigeonhole Principle, Permutations and Combinations.
Counting Discrete Mathematics.
Basic Counting Lecture 9: Nov 5, 6.
First lecture fsalamri Faten alamri.
Mathematics for Computer Science MIT 6.042J/18.062J
Now it’s time to look at…
Copyright © Zeph Grunschlag,
Copyright © Zeph Grunschlag,
Counting I: Choice Trees and Correspondences
Probability Notes Math 309.
Sets, Combinatorics, Probability, and Number Theory
Presentation transcript:

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

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?

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?

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?

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

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

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

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

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

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

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

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

Inclusion-Exclusion (3 Sets) A B C

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

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

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)}

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

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

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

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

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

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

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

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

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…

In-class Problems

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|

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

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

An Alternate Counting? Is this argument correct?

Algebra or Calculator Are these two the same?

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!

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

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

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

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)=??

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

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