Module #15: Combinatorics

Slides:



Advertisements
Similar presentations
COUNTING AND PROBABILITY
Advertisements

Permutations and Combinations Rosen 4.3. Permutations A permutation of a set of distinct objects is an ordered arrangement these objects. An ordered arrangement.
Advanced Counting Techniques Prof. Johnnie Baker
1 Combinatorics Rosen 6 th ed., § , § Combinatorics Count the number of ways to put things together into various combinations.Count the number.
1 Discrete Math CS 2800 Prof. Bart Selman Module Counting Chapter 5, Rosen.
CSE115/ENGR160 Discrete Mathematics 04/17/12
1 Section 4.1 Basics of Counting. 2 Basic Counting Principles: Sum Rule Suppose you have two tasks to perform: –The first task can be done in n 1 ways;
Permutations r-permutation (AKA “ordered r-selection”) An ordered arrangement of r elements of a set of n distinct elements. permutation of a set of n.
Recursive Definitions Rosen, 3.4 Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
CSE115/ENGR160 Discrete Mathematics 04/10/12
Combinations We should use permutation where order matters
Recursive Definitions Rosen, 3.4 Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
CS100 : Discrete Structures
Combinatorics 3/15 and 3/ Counting A restaurant offers the following menu: Main CourseVegetablesBeverage BeefPotatoesMilk HamGreen BeansCoffee.
Counting Chapter 6 With Question/Answer Animations.
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
Counting. Why counting  Determine the complexity of algorithms To sort n numbers, how many instructions are executed ?  Count the number of objects.
The Basics of Counting Section 6.1.
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
Fall 2002CMSC Discrete Structures1 One, two, three, we’re… Counting.
Chapter 3 Permutations and combinations
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.
Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl 1/37 Module.
Module #15: Combinatorics Rosen 5 th ed., §§ & §6.5 Now we are moving on to Ch. 4 It is the study of arrangement of objects e.g. enumeration, counting.
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,
11.1 CompSci 102© Michael Frank Today’s topics CountingCounting –Sum rule –Product rule –Tree diagrams –Inclusion/exclusion Reading: Sections 4.1Reading:
Discrete Structures Combinations. Order Doesn’t Matter In the previous section, we looked at two cases where order matters: Multiplication Principle –
2/24/20161 One, two, three, we’re… Counting. 2/24/20162 Basic Counting Principles Counting problems are of the following kind: “How many different 8-letter.
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
Section The Pigeonhole Principle If a flock of 20 pigeons roosts in a set of 19 pigeonholes, one of the pigeonholes must have more than 1 pigeon.
Main Menu Main Menu (Click on the topics below) Pigeonhole Principle Example Generalized Pigeonhole Principle Example Proof of Pigeonhole Principle Click.
Chapter 6 With Question/Answer Animations Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written.
ICS 253: Discrete Structures I Counting and Applications King Fahd University of Petroleum & Minerals Information & Computer Science Department.
11.1 CompSci 102© Michael Frank Today’s topics CountingCounting –Generalized Pigeonhole Principle –Permutations –Combinations –Binomial Coefficients –Writing.
COUNTING Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.
Example A standard deck of 52 cards has 13 kinds of cards, with four cards of each of kind, one in each of the four suits, hearts, diamonds, spades, and.
Developing Your Counting Muscles
Permutations and Combinations
CSC 321: Data Structures Fall 2015 Counting and problem solving
CSE15 Discrete Mathematics 04/19/17
ICS 253: Discrete Structures I
Chapter 5, Section 5.1 The Basics of Counting
Copyright © Zeph Grunschlag,
Today’s topics Counting Reading: Sections , 4.4 Upcoming
The Pigeonhole Principle
Discrete Structures for Computer Science
COCS DISCRETE STRUCTURES
CSC 321: Data Structures Fall 2016 Counting and proofs
Permutations and Combinations
The Pigeonhole Principle
Permutations and Combinations
Permutations and Combinations
Copyright © Zeph Grunschlag,
Counting Chapter 6 With Question/Answer Animations
CS 2210 Discrete Structures Counting
CS100: Discrete structures
Math/CSE 1019: Discrete Mathematics for Computer Science Fall 2011
Permutations and Combinations
Basic Counting.
COUNTING AND PROBABILITY
Discrete Mathematics and its Applications
CSC 321: Data Structures Fall 2018 Counting and proofs
Counting techniques Basic Counting Principles, Pigeonhole Principle, Permutations and Combinations.
Module #15: Combinatorics
Basic Counting Lecture 9: Nov 5, 6.
Discrete Mathematics and its Applications
Presentation transcript:

Module #15: Combinatorics Rosen 5th ed., §§4.1-4.3 & §6.5 ~19 slides, ~1 lecture 12/4/2018 (c)2001-2003, Michael P. Frank

Combinatorics The study of the number of ways to put things together into various combinations. E.g. In a contest entered by 100 people, how many different top-10 outcomes could occur? E.g. If a password is 6-8 letters and/or digits, how many passwords can there be? 12/4/2018 (c)2001-2003, Michael P. Frank

Sum and Product Rules Let m be the number of ways to do task 1 and n the number of ways to do task 2 (with each number independent of how the other task is done), and assume that no way to do task 1 simultaneously also accomplishes task 2. The sum rule: The task “do either task 1 or task 2, but not both” can be done in m+n ways. The product rule: The task “do both task 1 and task 2” can be done in mn ways. 12/4/2018 (c)2001-2003, Michael P. Frank

Set Theoretic Version If A is the set of ways to do task 1, and B the set of ways to do task 2, and if A and B are disjoint, then: The ways to do either task 1 or 2 are AB, and |AB|=|A|+|B| The ways to do both task 1 and 2 can be represented as AB, and |AB|=|A|·|B| 12/4/2018 (c)2001-2003, Michael P. Frank

IP Address Example Some facts about Internet Protocol vers. 4: Valid computer addresses are in one of 3 types: A class A IP address contains a 7-bit “netid” ≠ 17, and a 24-bit “hostid” A class B address has a 14-bit netid and a 16-bit hostid. A class C addr. Has 21-bit netid and an 8-bit hostid. The 3 classes have distinct headers (0, 10, 110) Hostids that are all 0s or all 1s are not allowed. How many valid computer addresses are there? e.g., ufl.edu is 128.227.74.58 12/4/2018 (c)2001-2003, Michael P. Frank

IP address solution (# addrs) = (# class A) + (# class B) + (# class C) (by sum rule) # class A = (# valid netids)·(# valid hostids) (by product rule) (# valid class A netids) = 27 − 1 = 127. (# valid class A hostids) = 224 − 2 = 16,777,214. Continuing in this fashion we find the answer is: 3,737,091,842 (3.7 billion IP addresses) 12/4/2018 (c)2001-2003, Michael P. Frank

Inclusion-Exclusion Principle Suppose that km of the ways of doing task 1 also simultanously accomplish task 2. (And thus are also ways of doing task 2.) Then the number of ways to accomplish “Do either task 1 or task 2” is mnk. Set theory: If A and B are not disjoint, then |AB|=|A||B||AB|. 12/4/2018 (c)2001-2003, Michael P. Frank

Inclusion/Exclusion Example Hypothetical rules for passwords: Passwords must be 2 characters long. Each password must be a letter a-z, a digit 0-9, or one of the 10 punctuation characters !@#$%^&*(). Each password must contain at least 1 digit or punctuation character. 12/4/2018 (c)2001-2003, Michael P. Frank

Setup of Problem A legal password has a digit or puctuation character in position 1 or position 2. These cases overlap, so the principle applies. (# of passwords w. OK symbol in position #1) = (10+10)·(10+10+26) (# w. OK sym. in pos. #2): also 20·46 (# w. OK sym both places): 20·20 Answer: 920+920−400 = 1,440 12/4/2018 (c)2001-2003, Michael P. Frank

Pigeonhole Principle A.k.a. Dirichlet drawer principle If ≥k+1 objects are assigned to k places, then at least 1 place must be assigned ≥2 objects. In terms of the assignment function: If f:A→B and |A|≥|B|+1, then some element of B has ≥2 preimages under f. I.e., f is not one-to-one. 12/4/2018 (c)2001-2003, Michael P. Frank

Example of Pigeonhole Principle There are 101 possible numeric grades (0%-100%) rounded to the nearest integer. There are >101 students in this class. Therefore, there must be at least one (rounded) grade that will be shared by at least 2 students at the end of the semester. I.e., the function from students to rounded grades is not a one-to-one function. 12/4/2018 (c)2001-2003, Michael P. Frank

Fun Pigeonhole Proof (Ex. 4, p.314) Theorem: nN,  a multiple m>0 of n  m has only 0’s and 1’s in its decimal expansion! Proof: Consider the n+1 decimal integers 1, 11, 111, …, 11. They have only n possible residues mod n. So, take the difference of two that have the same residue. The result is the answer! □ n+1 12/4/2018 (c)2001-2003, Michael P. Frank

A Specific Example Let n=3. Consider 1,11,111,1111. 1 mod 3 = 1 11 mod 3 = 2 111 mod 3 = 0  Lucky extra solution. 1,111 mod 3 = 1 1,111 − 1 = 1,110 = 3·370. It has only 0’s and 1’s in its expansion. Its residue mod 3 = 0, so it’s a multiple of 3. Note same residue. 12/4/2018 (c)2001-2003, Michael P. Frank

Generalized Pigeonhole Principle If N objects are assigned to k places, then at least one place must be assigned at least N/k objects. E.g., there are N=280 students in this class. There are k=52 weeks in the year. Therefore, there must be at least 1 week during which at least 280/52= 5.38=6 students in the class have a birthday. 12/4/2018 (c)2001-2003, Michael P. Frank

Proof of G.P.P. By contradiction. Suppose every place has < N/k objects, thus ≤ N/k−1. Then the total number of objects is at most So, there are less than N objects, which contradicts our assumption of N objects! □ 12/4/2018 (c)2001-2003, Michael P. Frank

G.P.P. Example Given: There are 280 students in the class. Without knowing anybody’s birthday, what is the largest value of n for which we can prove that at least n students must have been born in the same month? Answer: 280/12 = 23.3 = 24 12/4/2018 (c)2001-2003, Michael P. Frank

Permutations A permutation of a set S of objects is a sequence containing each object once. An ordered arrangement of r distinct elements of S is called an r-permutation. The number of r-permutations of a set with n=|S| elements is P(n,r) = n(n−1)…(n−r+1) = n!/(n−r)! 12/4/2018 (c)2001-2003, Michael P. Frank

Permutation Example A terrorist has planted an armed nuclear bomb in your city, and it is your job to disable it by cutting wires to the trigger device. There are 10 wires to the device. If you cut exactly the right three wires, in exactly the right order, you will disable the bomb, otherwise it will explode! If the wires all look the same, what are your chances of survival? P(10,3) = 10·9·8 = 720, so there is a 1 in 720 chance that you’ll survive! 12/4/2018 (c)2001-2003, Michael P. Frank

Combinations An r-combination of elements of a set S is simply a subset TS with r members, |T|=r. The number of r-combinations of a set with n=|S| elements is Note that C(n,r) = C(n, n−r) Because choosing the r members of T is the same thing as choosing the n−r non-members of T. 12/4/2018 (c)2001-2003, Michael P. Frank

Combination Example How many distinct 7-card hands can be drawn from a standard 52-card deck? The order of cards in a hand doesn’t matter. Answer C(52,7) = P(52,7)/P(7,7) = 52·51·50·49·48·47·46 / 7·6·5·4·3·2·1 17 10 7 8 2 52·17·10·7·47·46 = 133,784,560 12/4/2018 (c)2001-2003, Michael P. Frank