Outline. Content The basics of counting The pigeonhole principle Reading Chapter 5 IRIS H.-R. JIANG

Similar documents
6.1 Basics of counting

With Question/Answer Animations. Chapter 6

CPCS 222 Discrete Structures I Counting

Sec 5.1 The Basics of Counting

Counting. Chapter 6. With Question/Answer Animations

COUNTING TECHNIQUES. Prepared by Engr. JP Timola Reference: Discrete Math by Kenneth H. Rosen

Sec.on Summary. The Product Rule The Sum Rule The Subtraction Rule (Principle of Inclusion- Exclusion)

Discrete Mathematics: Logic. Discrete Mathematics: Lecture 15: Counting

CS100: DISCRETE STRUCTURES. Lecture 8 Counting - CH6

Topics to be covered

What is counting? (how many ways of doing things) how many possible ways to choose 4 people from 10?

Today s Topics. Sometimes when counting a set, we count the same item more than once

Math 365 Wednesday 2/20/19 Section 6.1: Basic counting

Discrete Mathematics. Spring 2017

Combinatorics, the study of arrangements of objects, is an important part of discrete mathematics.

2. How many bit strings of length 10 begin with 1101? a b. 2 6 c. 2 4 d. None of the above.

The Product Rule can be viewed as counting the number of elements in the Cartesian product of the finite sets

With Question/Answer Animations. Chapter 6

Counting: Basics. Four main concepts this week 10/12/2016. Product rule Sum rule Inclusion-exclusion principle Pigeonhole principle

In how many ways can we paint 6 rooms, choosing from 15 available colors? What if we want all rooms painted with different colors?

12. 6 jokes are minimal.

Mathematical Foundations of Computer Science Lecture Outline August 30, 2018

The Product Rule The Product Rule: A procedure can be broken down into a sequence of two tasks. There are n ways to do the first task and n

Math 1111 Math Exam Study Guide

CMath 55 PROFESSOR KENNETH A. RIBET. Final Examination May 11, :30AM 2:30PM, 100 Lewis Hall

Math 1111 Math Exam Study Guide

MATH 215 DISCRETE MATHEMATICS INSTRUCTOR: P. WENG

THE PIGEONHOLE PRINCIPLE. MARK FLANAGAN School of Electrical and Electronic Engineering University College Dublin

Elementary Combinatorics

MAT104: Fundamentals of Mathematics II Summary of Counting Techniques and Probability. Preliminary Concepts, Formulas, and Terminology

The study of probability is concerned with the likelihood of events occurring. Many situations can be analyzed using a simplified model of probability

Reading 14 : Counting

MC215: MATHEMATICAL REASONING AND DISCRETE STRUCTURES

CHAPTER 7 Probability

1. An office building contains 27 floors and has 37 offices on each floor. How many offices are in the building?

Counting in Algorithms

Principles of Counting. Notation for counting elements of sets

Math236 Discrete Maths with Applications

Jong C. Park Computer Science Division, KAIST

CS 3233 Discrete Mathematical Structure Midterm 2 Exam Solution Tuesday, April 17, :30 1:45 pm. Last Name: First Name: Student ID:

Principle of Inclusion-Exclusion Notes

The Pigeonhole Principle

Probability and Counting Techniques

CSE 312: Foundations of Computing II Quiz Section #2: Inclusion-Exclusion, Pigeonhole, Introduction to Probability (solutions)

9.5 Counting Subsets of a Set: Combinations. Answers for Test Yourself

CS1802 Week 3: Counting Next Week : QUIZ 1 (30 min)

Block 1 - Sets and Basic Combinatorics. Main Topics in Block 1:

A theorem on the cores of partitions

Honors Precalculus Chapter 9 Summary Basic Combinatorics

LESSON 2: THE INCLUSION-EXCLUSION PRINCIPLE

Week 1. 1 What Is Combinatorics?

Counting and Probability Math 2320

Rosen, Discrete Mathematics and Its Applications, 6th edition Extra Examples

Discrete Structures for Computer Science

CSCI FOUNDATIONS OF COMPUTER SCIENCE

Section Summary. Finite Probability Probabilities of Complements and Unions of Events Probabilistic Reasoning

CSE 312: Foundations of Computing II Quiz Section #2: Combinations, Counting Tricks (solutions)

Chapter 7. Intro to Counting

NANYANG TECHNOLOGICAL UNIVERSITY SEMESTER II EXAMINATION MH1301 DISCRETE MATHEMATICS. Time Allowed: 2 hours

MA 524 Midterm Solutions October 16, 2018

November 6, Chapter 8: Probability: The Mathematics of Chance

Lecture 2: Sum rule, partition method, difference method, bijection method, product rules

The probability set-up

Probability MAT230. Fall Discrete Mathematics. MAT230 (Discrete Math) Probability Fall / 37

EECS 203 Spring 2016 Lecture 15 Page 1 of 6

1. The empty set is a proper subset of every set. Not true because the empty set is not a proper subset of itself! is the power set of A.

Solution: This is sampling without repetition and order matters. Therefore

NON-OVERLAPPING PERMUTATION PATTERNS. To Doron Zeilberger, for his Sixtieth Birthday

Foundations of Computing Discrete Mathematics Solutions to exercises for week 12

7.1 Experiments, Sample Spaces, and Events

Olympiad Combinatorics. Pranav A. Sriram

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

Week 1: Probability models and counting

It is important that you show your work. The total value of this test is 220 points.

Intermediate Math Circles November 1, 2017 Probability I

MATHEMATICS 152, FALL 2004 METHODS OF DISCRETE MATHEMATICS Outline #10 (Sets and Probability)

Math 42, Discrete Mathematics

Test 3 (Version 1) Fall 2014

ON SPLITTING UP PILES OF STONES

Math 3012 Applied Combinatorics Lecture 2

March 5, What is the area (in square units) of the region in the first quadrant defined by 18 x + y 20?

SET THEORY AND VENN DIAGRAMS

Exercises Exercises. 1. List all the permutations of {a, b, c}. 2. How many different permutations are there of the set {a, b, c, d, e, f, g}?

The probability set-up

1 = 3 2 = 3 ( ) = = = 33( ) 98 = = =

Week 3 Classical Probability, Part I

Chapter 1. Probability

Massachusetts Institute of Technology 6.042J/18.062J, Spring 04: Mathematics for Computer Science April 16 Prof. Albert R. Meyer and Dr.

Section Introduction to Sets

Theory of Probability - Brett Bernstein

Slide 1 Math 1520, Lecture 13

Cardinality. Hebrew alphabet). We write S = ℵ 0 and say that S has cardinality aleph null.

Chapter 2 Basic Counting

Unique Sequences Containing No k-term Arithmetic Progressions

8.2 Union, Intersection, and Complement of Events; Odds

Week 6: Advance applications of the PIE. 17 and 19 of October, 2018

CONTENTS GRAPH THEORY

The tenure game. The tenure game. Winning strategies for the tenure game. Winning condition for the tenure game

Mathematics Competition Practice Session 6. Hagerstown Community College: STEM Club November 20, :00 pm - 1:00 pm STC-170

Multiples and Divisibility

Transcription:

CHAPTER 5 COUNTING

Outline 2 Content The basics of counting The pigeonhole principle Reading Chapter 5 Most of the following slides are by courtesy of Prof. J.-D. Huang and Prof. M.P. Frank

Combinatorics 3 Combinatorics The study of arrangements of objects Studied since 17th century for gambling / enumeration Objective of counting The complexity of algorithms There are enough phone numbers / IP addresses 賭場賠率

Basic Principles 4 In this section, we study 2 basic counting principles product rule sum rule

Product rule 5 Product rule Suppose that a procedure can be broken down into a sequence of 2 tasks If there are n 1 ways to do the first task and n 2 ways to do the second task after the first task has been done Then there are n 1 *n 2 ways to do the procedure Extended product rule suppose that a procedure can be broken down into a sequence of m tasks, T 1, T 2,, T m if there are n i ways to do the task T i after Task T 1 ~T i-1 has been done then there are n 1 * n 2 * * n m ways to do the procedure

Simple Examples 6 Labeling chairs with a letter and a positive integer 100 26*100 How many different bit strings are there of length 7? 2 7 How many different license plates are available if each plate contains a sequence of 3 letters followed by 3 digits? 26*26*26*10*10*10 How many functions are there from a set with m elements to one with n elements? n m How many one-to-one functions are there from a set with m elements to one with n elements? (m n) n*(n-1)* *(n-m+1)

Telephone Numbering Plan 7 Phone numbering 10 digits; 3-digit area code, 3-digit office code, 4-digit station code X: 0~9, N: 2~9, Y: 0~1 How many available numbers in NYX-NNX-XXXX format? How many available numbers in NXX-NXX-XXXX format?

Step Counts in Programs 8 k := 0 for i 1 := 1 to n 1 for i 2 := 1 to n 2 for i m := 1 to n m k := k + 1 Q: What is the value of k at last? A: n 1 * n 2 * * n m

Subsets of a Finite Set 9 Use the product rule to show that the number of different subsets of a finite set S is 2 S We have proved this before by mathematical induction Now in different way To form a subset T of S, for each element s S, you have 2 choices; you can choose to add s into T or not By the product rule, there are 2 S different subsets

Cartesian Product 10 If A 1, A 2,, A m are finite sets, then the number of elements in the Cartesian product of these sets is the product of the number of elements in each set That is, A 1 x A 2 x x A m = A 1 * A 2 * * A m

Sum Rule 11 The sum rule If a task can be done either in n 1 ways or in n 2 ways None of the set of n 1 ways is the same as any of the set of n 2 ways Then there are n 1 + n 2 ways to do the task The extended sum rule If the task can be done in n 1, n 2,, or n m ways No 2 of these ways are the same Then there are n 1 + n 2 + + n m ways to do the task

Simple Examples 12 Either a professor or a student can be selected as a committee member. How many different choices if there are 37 professors and 83 students? 37+83=120 A student can choose a project from 1 of 3 lists. The 3 lists contain 23, 15, and 19 possible projects, respectively. No project is on more than one list. How many possible projects are there to choose from? 23+15+19=57

13 Step Counts in Programs k := 0 for i 1 := 1 to n 1 k := k + 1 for i 2 := 1 to n 2 k := k + 1 for i m := 1 to n m k := k + 1 Q: What is the value of k at last? A: n 1 + n 2 + + n m

Sum Rule in Disjoint Sets 14 If A 1, A 2,, A m are disjoint finite sets, then the number of elements in the union of these sets is the sum of the number of elements in each set That is, A 1 A 2 A m = A 1 + A 2 + + A m

15 Number of Available Variable Names For some computer language The name of a variable is a string of 1 or 2 alphanumeric characters and case-insensitive A variable must begin with a letter 5 2-character strings are reserved for system use How many different variable names are available? V 1 = 26; V 2 = 26*(26+10)-5 = 931; V 1 +V 2 = 26 + 931 = 957

Passwords 16 Password rule 6~8 characters long each character is a lowercase letter or a digit must contain at least 1 digit The answer is 2,648,483,063,360 P 6 =36 6-26 6 P 7 =36 7-26 7 P 8 =36 8-26 8

IP Addresses 17 How many available addresses for Class A, B, and C? Restrictions 1111111 cannot be a netid for class A Hostids consisting of all 0s or 1s are not allowed The answer is 3,737,091,842 IPv4 (Version 4 of the Internet Protocol) x A =(2 7-1)(2 24-2) x B =(2 14-1)(2 16-2) x C =(2 21-1)(2 8-2)

Inclusion-Exclusion Principle 18 The sum rule does not work if some ways of 2 tasks are the same Principle of inclusion-exclusion Correctly count the number of ways to do 1 of the 2 tasks We add the number of ways to do each of the 2 tasks and then subtract the number of ways to do both tasks

Example 19 How many bit strings of length 8 either start with a 1 bit or end with 2 bits 00? Starting with 1 : 2 7 = 128 Ending with 00: 2 6 = 64 Starting with 1 & ending with 00: 2 5 = 32 By inclusion-exclusion rule: 128 + 64 32 = 160

Inclusion-Exclusion in Sets 20 Assume A 1 and A 2 are sets T 1 /T 2 is the task of choosing an element from A 1 /A 2 (a different chosen element is a different way) There are A 1 ways to do T 1 and A 2 ways to do T 2 The number of ways to do either T 1 or T 2 A 1 A 2 = A 1 + A 2 A 1 A 2 The principle of inclusion-exclusion can be generalized to find the number of ways to do one of n different tasks

Tree Diagrams 21 Some counting problems can be solved by using tree diagrams How many bit strings of length 4 do not have 2 consecutive 1s?

22 by Tree Diagrams Best of Five (Bo5): 兩隊比賽五戰三勝共有幾種結局?

The Pigeonhole Principle 23 The pigeonhole principle If k+1 or more objects are placed into k boxes, then there is at least one box containing 2 or more of the objects.

Examples 24 In any group of 367 people, there must be at least 2 people with the same birthday In any group of 27 English words, there must be at least 2 that begins with the same initial letter How many students must be in a class to guarantee that at least 2 students get the same score on the final exam if the grade is from 0~100? 102

Advanced Example 25 DIY: Show that for every positive integer n there is a multiple of n that has only 0s and 1s in its decimal expansion Consider the n+1 integers: 1, 11, 111,, 111 11 n+1 1s There are only n possible remainders when an integer is divided by n

Generalized Pigeonhole Principle 26 Example Among any set of 21 digits (0~9 numbers), there must be at least 3 that are the same The generalized pigeonhole principle If N objects are placed into k boxes, then there is at least one box containing at least N/k of the objects Pf: By contradiction! Suppose none of boxes contains more than N/k - 1 objects. Then, the total number of objects is at most k * ( N/k - 1) < k * ((N/k + 1) 1) = N

Examples 27 Among 100 people there are at least 100/12 =9 people were born in the same month What is the minimum number of students in a class that at least 6 will receive the same grade? (A, B, C, D, F) N/5 =6 N 26 DIY: How many cards must be selected from a standard deck of 52 cards to guarantee that at least 3 cards of the same suit are chosen? DIY: How many must be selected to guarantee that at least 3 hearts are selected?

Advanced Examples (1/4) 28 Example suppose there are 15 PCs and 10 servers a cable can be used to connect a PC to a server What is the minimum number of cables to guarantee any set of 10 PCs can access different servers? 10 (one-to-one for the first 10 PCs) + 5*10 (full connections) = 60

Advanced Examples (2/4) 29 Example During a month with 30 days A baseball team plays at least 1 game a day, but no more than 45 games in this month Show that there must be a period of some number of consecutive days during which the team must play exactly 14 games Pf: let a j be the number of games played on and before the jth day Hence, a 1, a 2,, a 30 is an increasing sequence of distinct integers with 1 a j 45 a 1 +14, a 2 +14,, a 30 +14 is also an increasing sequence of distinct integers with 15 a k 59 These 60 positive integers are 59 2 integers must be identical some a k must be equal to a j +14

Advanced Examples (3/4) 30 Show that among any n+1 positive integers not exceeding 2n, there must be an integer that divides one of the other integers n+1 positive integers: a 1, a 2,, a n+1 a i = 2 ki * q i, where k i is a nonnegative integer and q i is odd Since there are only n odd integers not exceeding 2n, at least 2 of the q 1, q 2,, q n+1 must be equal Assume q m and q n are equal, then a m divides a n or a n divides a m

Advanced Examples (4/4) 31 DIY: Every sequence of n 2 + 1 distinct real numbers containing a subsequence of length n+1 that is either strictly increasing or strictly decreasing e.g., 8, 11, 9, 1, 4, 6, 12, 10, 5, 7; 10 elements strictly increasing: 1, 4, 6, 12 strictly decreasing: 11, 9, 6, 5 Pf: By contradiction n 2 +1 real: a 1, a 2,, a n2+1 (i k, d k ) for an a k : i k (or d k ) is the length of the longest increasing ( or decreasing) sequence starting at a k Suppose there are no increasing/decreasing subsequences of length n+1, i.e., at most length n 1 i k, d k n only n 2 (i k, n k ) pairs By the pigeonhole principle, there exists s<t with the same (i, d) pair, if a s < a t, i s = i t i s i t +1 (include a s ) Similarly, a s > a t leads to a contradiction, too.