Math.3336: Discrete Mathematics. Combinatorics: Basics of Counting

Similar documents
Math.3336: Discrete Mathematics. Advanced Counting Techniques

Math.3336: Discrete Mathematics. Cardinality of Sets

Math.3336: Discrete Mathematics. Applications of Propositional Logic

Math.3336: Discrete Mathematics. Chapter 9 Relations

Math.3336: Discrete Mathematics. Propositional Equivalences

Math.3336: Discrete Mathematics. Primes and Greatest Common Divisors

Math.3336: Discrete Mathematics. Proof Methods and Strategy

Math.3336: Discrete Mathematics. Mathematical Induction

Math.3336: Discrete Mathematics. Nested Quantifiers/Rules of Inference

Math.3336: Discrete Mathematics. Nested Quantifiers

Math.3336: Discrete Mathematics. Primes and Greatest Common Divisors

Recursive Definitions

MATH 243E Test #3 Solutions

Counting. Math 301. November 24, Dr. Nahid Sultana

Announcements. CSE 321 Discrete Structures. Counting. Counting Rules. Important cases of the Product Rule. Counting examples.

MATH 137 : Calculus 1 for Honours Mathematics. Online Assignment #2. Introduction to Sequences

Discrete Mathematics & Mathematical Reasoning Chapter 6: Counting

Counting Methods. CSE 191, Class Note 05: Counting Methods Computer Sci & Eng Dept SUNY Buffalo

Lecture 4: Counting, Pigeonhole Principle, Permutations, Combinations Lecturer: Lale Özkahya

Counting. Spock's dilemma (Walls and mirrors) call it C(n,k) Rosen, Chapter 5.1, 5.2, 5.3 Walls and Mirrors, Chapter 3 10/11/12

MATH 10B METHODS OF MATHEMATICS: CALCULUS, STATISTICS AND COMBINATORICS

Course Staff. Textbook


Counting. Mukulika Ghosh. Fall Based on slides by Dr. Hyunyoung Lee

n CS 160 or CS122 n Sets and Functions n Propositions and Predicates n Inference Rules n Proof Techniques n Program Verification n CS 161

Binomial Coefficients MATH Benjamin V.C. Collins, James A. Swenson MATH 2730

Inclusion and Exclusion Principle

Unit 8: Statistics. SOL Review & SOL Test * Test: Unit 8 Statistics

Combinatorics. But there are some standard techniques. That s what we ll be studying.

Chapter 7. Inclusion-Exclusion a.k.a. The Sieve Formula

Johns Hopkins Math Tournament Proof Round: Automata

Notes. Combinatorics. Combinatorics II. Notes. Notes. Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry. Spring 2006

Chapter 8 Sequences, Series, and Probability

Math 55 Second Midterm Exam, Prof. Srivastava April 5, 2016, 3:40pm 5:00pm, F295 Haas Auditorium.

MATH c UNIVERSITY OF LEEDS Examination for the Module MATH2210 (May/June 2004) INTRODUCTION TO DISCRETE MATHEMATICS. Time allowed : 2 hours

W3203 Discrete Mathema1cs. Coun1ng. Spring 2015 Instructor: Ilia Vovsha.

Slides for a Course Based on the Text Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen

Chapter 2 Class Notes

1 Basic Combinatorics

EECS 1028 M: Discrete Mathematics for Engineers

Some Review Problems for Exam 3: Solutions

9.1 HW (3+3+8 points) (Knapsack decision problem NP-complete)

Executive Assessment. Executive Assessment Math Review. Section 1.0, Arithmetic, includes the following topics:

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

Summer 2017 June 16, Written Homework 03

Math 230 Final Exam, Spring 2008

Discrete Probability

Senior Math Circles March 3, 2010 Counting Techniques and Probability II

CS103 Handout 08 Spring 2012 April 20, 2012 Problem Set 3

2 - Strings and Binomial Coefficients

An Introduction to Combinatorics

Lecture 02: Combinatorics. Lisa Yan June 27, 2018

God doesn t play dice. - Albert Einstein

2!3! (9)( 8x3 ) = 960x 3 ( 720x 3 ) = 1680x 3

2030 LECTURES. R. Craigen. Inclusion/Exclusion and Relations

Mathematics: Year 12 Transition Work

CS Homework 2: Combinatorics & Discrete Events Due Date: September 25, 2018 at 2:20 PM

Name: Exam 2 Solutions. March 13, 2017

ICS141: Discrete Mathematics for Computer Science I

Advanced Counting Techniques. Chapter 8

Some Review Problems for Exam 3: Solutions

Solution: There are 30 choices for the first person to leave, 29 for the second, etc. Thus this exodus can occur in. = P (30, 8) ways.

MATH STUDENT BOOK. 12th Grade Unit 9

CS 154 Introduction to Automata and Complexity Theory

MATH 341, Section 001 FALL 2014 Introduction to the Language and Practice of Mathematics

1.1 Administrative Stuff

Grade 6 Math Circles November 17, 2010 Sequences

Math 20 Spring Discrete Probability. Midterm Exam

CSE 240 Logic and Discrete Mathematics

F 2k 1 = F 2n. for all positive integers n.

Basic Combinatorics. Math 40210, Section 01 Fall Homework 8 Solutions

CSCI 150 Discrete Mathematics Homework 5 Solution

CS 340: Discrete Structures for Engineers

CS 154 Formal Languages and Computability Assignment #2 Solutions

CS446: Machine Learning Spring Problem Set 4

Math 463/563 Homework #2 - Solutions

Admission-Tests GMAT GMAT.

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

Introduction Propositional Logic

Math 461 B/C, Spring 2009 Midterm Exam 1 Solutions and Comments

Problem set 1. (c) Is the Ford-Fulkerson algorithm guaranteed to produce an acyclic maximum flow?

Essential Question: What is a complex number, and how can you add, subtract, and multiply complex numbers? Explore Exploring Operations Involving

Foundations of Computer Science Lecture 14 Advanced Counting

MTH 310, Section 001 Abstract Algebra I and Number Theory. Sample Midterm 1

ABOUT THE CLASS AND NOTES ON SET THEORY

Important Dates. Non-instructional days. No classes. College offices closed.

MATH 114 Fall 2004 Solutions to practice problems for Final Exam

Review problems solutions

CMPSCI 240: Reasoning about Uncertainty

MATH 363: Discrete Mathematics

Posted Thursday February 14. STUDY IN-DEPTH...the posted solutions to homeworks 1-3. Compare with your own solutions.

Vocabulary Polynomial: A monomial or the sum of two or more monomials whose exponents are positive. Example: 5a 2 + ba 3. 4a b, 1.

Math Review. for the Quantitative Reasoning measure of the GRE General Test

Introduction to Combinatorial Mathematics

You separate binary numbers into columns in a similar fashion. 2 5 = 32

MATH STUDENT BOOK. 11th Grade Unit 9

CS103 Handout 22 Fall 2012 November 30, 2012 Problem Set 9

CMSC 330: Organization of Programming Languages

Carleton University. Final Examination Fall DURATION: 2 HOURS No. of students: 195

Get started [Hawkes Learning] with this system. Common final exam, independently administered, group graded, grades reported.

Transcription:

Math.3336: Discrete Mathematics Combinatorics: Basics of Counting Instructor: Dr. Blerina Xhabli Department of Mathematics, University of Houston https://www.math.uh.edu/ blerina Email: blerina@math.uh.edu Fall 2018 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 1/31

Assignments to work on Homework #7 due Wednesday, 10/31, 11:59pm (to be posted on Wednesday, 10/24) No credit unless turned in by 11:59pm on due date Late submissions not allowed, but lowest homework score dropped when calculating grades Homework will be submitted online in your CASA accounts. You can find the instructions on how to upload your homework in our class webpage. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 2/31

Chapter 6 Counting Chapter 6 Overview The Basics of Counting Section 6.1 The Pigeonhole Principle Section 6.2 Permutations and Combinations Section 6.3 Binomial Coefficients and Identities Section 6.4 Generalized Permutations and Combinations Section 6.5 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 3/31

Introduction Consider a set of objects and a property of interest Often, we want to know how many of these objects have the desired property Example: How many possible passwords are there if a password must contain 6-8 characters? These kinds of problems arise frequently in computer science Combinatorics (counting) deals with these questions Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 4/31

Section 6.1 Basic Counting Rules Counting problems can be hard useful to decompose Two basic very useful decomposition rules: 1 Product rule: useful when task decomposes into a sequence of independent tasks 2 Sum rule: decomposes task into a set of alternatives Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 5/31

Product Rule Suppose a task A can be decomposed into a sequence of two independent tasks B and C n 1 ways of doing B n 2 ways of doing C Product rule: Then, there are n 1 n 2 ways of doing A Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 6/31

Example 1 New company with 12 offices and 2 employees Kate and Jack How many ways to assign different offices to Kate and Jack? Decomposition: First assign office to Kate, then to Jack There are 12 ways to assign an office to Kate b/c 12 offices Once we assign office to Kate, only 11 offices left Thus, 11 ways to assign office to Jack By product rule, 12 11 = 132 ways to assign offices Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 7/31

Example 2 Chairs in auditorium labeled with a letter (A-Z) and an integer [1, 100]. What is the max number of chairs that can be labeled? Observe: Max # of labeled chairs = # of different labelings Same as How many different labelings for a chair? Decomposition: First assign letter, then integer to chair 26 ways to assign letter, 100 ways to assign integer By product rule, 26 100 = 2600 max labels Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 8/31

Extended Product Rule We formulated product rule for decomposition into 2 tasks But generalizes to decomposition into any k tasks Suppose task A decomposes to sequence of tasks A 1,... A k If there are n 1 ways of doing A 1,..., n k ways of doing A k, then there are n 1 n 2... n k ways of doing A Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 9/31

Example 3 A bitstring is a string where each character is either 0 or 1 How many different bit strings of length 7 are there? Decomposition: First assign bit to first character, then to second,..., then to seventh 2 ways to assign to first, 2 ways to assign to second etc. By extended product rule: 2 2... 2 (7 times) This is 2 7 = 128 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 10/31

Example 4 Each license plate consists of 3 letters followed by 3 digits How many different license plates are there? Decomposition: First assign first letter, then second, then third; then assign first digit, second digit, third digit 26 ways to assign each letter, 10 ways to assign a digit By product rule, 26 3 10 3 = 17, 576, 000 license plates Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 11/31

Counting One-to-One Functions How many one-to-one functions are there from a set with 3 elements to a set with 5 elements? Recall: In a one-to-one function, different elements in domain cannot be assigned to same element in codomain Decomposition: Assign first element in domain, then second element, then third element 5 ways to assign first element 4 ways to assign second element 3 ways to assign third element Thus, 5 4 3 = 60 one-to-one functions Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 12/31

Sum Rule Counting problems can be hard useful to decompose Two basic very useful decomposition rules: 1 Product rule 2 Sum rule Suppose a task A can be done either in way B or in way C Suppose there are n 1 ways to do B, and n 2 ways to do C Sum rule: There are n 1 + n 2 ways to do A. Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 13/31

Example 1 Suppose either a CS faculty or CS student must be chosen as representative for a committee There are 14 faculty, and 50 majors How many ways are there to choose the representative? By the sum rule, 50 + 14 = 64 ways Note: Just like the product rule, the sum rule can be extended to more than two tasks Extended sum rule: If task can be done in one of n 1 or n 2, or..., n k ways, then there are n 1 + n 2 +... + n k ways of doing it Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 14/31

Example 2 A student can choose a senior project from one of three lists First list contains 23 projects; second list has 15 projects, and third has 19 projects Also, no project appears on more than one list How many different projects can student choose? By sum rule, 23 + 15 + 19 = 57 What if some of the projects appeared on both lists? Caveat: For sum rule to apply, the possibilities must be mutually exclusive Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 15/31

More Complex Counting Problems Problems so far required either only product or only sum rule But more complex problems require a combination of both! Example: In BASIC programming language, a variable name is a string of one or two characters. A character is either a letter [a-z] or a digit [0,9]. First character in the string must be a letter. How many possible variable names are there? Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 16/31

Example, cont. First, decompose using sum rule. Variable name is either one character or two characters Compute number n 1 of one character names Compute number n 2 of two character names By sum rule, there is n 1 + n 2 names First compute n 1 : How many 1 character names are there? n 1 = 26 b/c first character must be letter Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 17/31

Example, cont. Now, compute n 2 : How many 2 character names are there? For this, decompose using product rule 26 ways to assign first character 36 ways to assign second character By product rule, n 2 = 26 36 = 936 Number of variable names = n 1 + n 2 = 26 + 936 = 962 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 18/31

Another Example A password must be six to seven characters long A character is upper case letter or digit Each password must contain at least one digit How many possible passwords? First decompose using sum rule: either six or seven characters Thus, number of possible passwords is n 6 + n 7 where n i is number of passwords with i characters Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 19/31

Example, cont. Computing n 6 : How many six-character passwords are there containing at least one digit? For this, compute the total number of six-character passwords; then subtract number of passwords without any digits? Total # of 6-char passwords: Using product rule, 36 6 # of 6-char passwords without any digits: Same as number of 6-char passwrods containing only characters Again, using product rule, 26 6 Thus, n 6 = 36 6 26 6 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 20/31

Example, cont. Computing n 7 : How many seven-character passwords are there containing at least one digit? n 7 = Total - # without any digits Total # of 7-char passwords = 36 7 Those without any digits: 26 7 n 7 = 36 7 26 7 Total number of passwords = n 6 + n 7 = 72, 200, 220, 480 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 21/31

Example 3 How many bitstrings are there of length 6 that do not have two consecutive 1 s? Let F (n) denote the number of bitstrings of length n that do not have two consecutive 1 s We ll first derive a recursive equation to characterize F (n) By the sum rule, F (n) is the sum of: 1 # of n-bit strings starting with 1 not containing 11 2 # of n-bit strings starting with 0 not containing 11 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 22/31

Example 3, cont. How many n-bit strings are there starting with 1 and not containing 11? Since we don t want two consecutive 1 s, second bit must be 0 But the rest can be anything as long as it doesn t contain two consecutive 1 s Thus, the rest = number of bitstrings of length n 2 not containing two consecutive 1 s But this is precisely F (n 2)! Thus, by product rule, there are 1 1 F (n 2) = F (n 2) n-bit strings starting with 1 and not containing 11 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 23/31

Example 3, cont. How many n-bit strings are there starting with 0 and not containing 11? First bit must be 0 but rest can be anything as long as it doesn t contain 11 How many ways of forming the rest? # of bitstrings of length n 1 not containing 11: F (n 1) By product rule, number of n-bit strings starting with 0, not containing 11 is 1 F (n 1) = F (n 1) Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 24/31

Example 3, cont. Recall: F (n) is sum of: 1 # of n-bit strings starting with 1 not containing 11 2 # of n-bit strings starting with 0 not containing 11 We determined that (1) is F (n 2) We determined that (2) is F (n 1) Therefore, F (n) = F (n 1) + F (n 2) This is a recursive definition, but what are the base cases? Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 25/31

Example 3, cont. What is F (1)? 2 What is F (2)? 2 2 1 = 3 Original question asks for F (6) Using base cases and recursive definition: F (3) = F (1) + F (2) = 5 F (4) = F (2) + F (3) = 8 F (5) = F (3) + F (4) = 13 F (6) = F (4) + F (5) = 21 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 26/31

Recall: Sum Rule Recall: Sum rule only applies if a task is as disjunction of two mutually exclusive tasks What do we do if the tasks aren t mutually exclusive? Example: You can choose from set A or set B, but they have some elements in common In such cases, the sum rule is not applicable because common elements counted twice Fortunately, there is a generalization of the sum rule called the inclusion-exclusion principle Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 27/31

The Inclusion-Exclusion Principle Suppose a set A can be written as union of sets B and C Inclusion-Exclusion Principle: A = B + C B C A C B Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 28/31

Inclusion-Exclusion Principle Example How many bit strings of length 8 either start with 1 or end with two bits 00? Let B be the set of bitstrings that start with 1 Let C be the set of bitstrings that end with 00 We want B C By the inclusion-exclusion principle, B C = B + C B C Thus, compute B, C and B C Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 29/31

Example, cont. First compute B, bitstrings of length 8 that start with 1 By product rule, B = 1 2 7 = 128 Now compute C, bitstrings of length 8 ending in 00 By product rule, C = 2 6 1 1 = 64 Now compute B C, those starting with 1 and ending in 00 By product rule, B C = 1 2 5 1 1 = 32 Number of 8-bit srings that start with 1 and end in 00: 128 + 64 32 = 160 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 30/31

Another Example A company receives 350 applications for job positions 220 of applicants are CS majors 147 of applicants are business majors 51 are double CS and business majors How many are neither CS nor business majors? B CS = 220 + 147 51 = 316 316 applicants are either CS or business majors The remaining applicants are neither business nor CS: 350 316 = 34 Instructor: Dr. Blerina Xhabli, University of Houston Math.3336: Discrete Mathematics Combinatorics: Basics of Counting 31/31