after UCI ICS/Math 6A, Summer 2007 6-Counting-1 Counting: Product and Sum Rules Product Rule: Assuming a)We need to.

Slides:



Advertisements
Similar presentations
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.
Advertisements

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.
Recursively Defined Functions
The Pigeonhole Principle
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.
The Pigeonhole Principle
Copyright © Zeph Grunschlag, Counting Techniques Zeph Grunschlag.
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;
CSE115/ENGR160 Discrete Mathematics 04/10/12
CSE 321 Discrete Structures Winter 2008 Lecture 16 Counting.
Combinations We should use permutation where order matters
Pigeonhole.
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.
Discrete Mathematics CS 2610 March 26, 2009 Skip: structural induction generalized induction Skip section 4.5.
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.
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
Fall 2002CMSC Discrete Structures1 One, two, three, we’re… Counting.
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.
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 Basics of Counting Section 6.1.
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.
5.2 Trees  A tree is a connected graph without any cycles.
Counting CSC-2259 Discrete Structures Konstantin Busch - LSU1.
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,
Counting Techniques. L172 Agenda Section 4.1: Counting Basics Sum Rule Product Rule Inclusion-Exclusion.
Discrete Structures Counting (Ch. 6)
Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)
Counting.
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.
The Pigeonhole Principle Alan Kaylor Cline. The Pigeonhole Principle Statement Children’s Version: “If k > n, you can’t stuff k pigeons in n holes without.
Section Basic Counting Principles: The Product Rule The Product Rule: A procedure can be broken down into a sequence of two tasks. There are n 1.
CS 104: Discrete Mathematics
L14: Permutations, Combinations and Some Review EECS 203: Discrete Mathematics.
The Pigeonhole Principle. Pigeonhole principle The pigeonhole principle : If k is a positive integer and k+1 or more objects are placed into k boxes,
Main Menu Main Menu (Click on the topics below) Pigeonhole Principle Example Generalized Pigeonhole Principle Example Proof of Pigeonhole Principle Click.
ICS 253: Discrete Structures I Counting and Applications King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Chapter 5 Counting 歐亞書局.
COUNTING Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.
CSC 321: Data Structures Fall 2015 Counting and problem solving
ICS 253: Discrete Structures I
Chapter 5, Section 5.1 The Basics of Counting
Copyright © Zeph Grunschlag,
The Pigeonhole Principle
Discrete Structures for Computer Science
COCS DISCRETE STRUCTURES
CSC 321: Data Structures Fall 2016 Counting and proofs
Copyright © Zeph Grunschlag,
Recursively Defined Functions
CS100: Discrete structures
Discrete Structures for Computer Science
Module #15: Combinatorics
CSE 321 Discrete Structures
CSE 321 Discrete Structures
CSC 321: Data Structures Fall 2018 Counting and proofs
Counting techniques Basic Counting Principles, Pigeonhole Principle, Permutations and Combinations.
Module #15: Combinatorics
The Basis of Counting.
Representations of Integers
Discrete Mathematics and its Applications
Copyright © Zeph Grunschlag,
Copyright © Zeph Grunschlag,
Counting Elements of Disjoint Sets: The Addition Rule
The Pigeonhole Principle
Presentation transcript:

after UCI ICS/Math 6A, Summer Counting-1 Counting: Product and Sum Rules Product Rule: Assuming a)We need to perform procedure 1 AND procedure 2. b)There are n 1 ways to perform procedure 1 and c)n 2 ways to perform procedure 2. There are n 1n 2 ways to perform procedure 1 AND procedure 2. Sum Rule: Assuming a)We need to perform procedure 1 OR procedure 2. b)There are n 1 ways to perform procedure 1 and c)n 2 ways to perform procedure 2. There are n 1 +n 2 ways to perform procedure 1 OR procedure 2. This “OR” is an “exclusive OR.” One choice or the other, but not both.

after UCI ICS/Math 6A, Summer Counting-2 Counting Examples: Product Rule Q. How many ways can we label a chair if each label consists of both a letter AND a number between 1 and 50, inclusive? There are 26 possibilities for the letter AND 50 for the number… A: 26x50=1300 Q. With 31 flavors of ice cream, 4 sizes of serving, and a choice of “cone” or “dish,” how many different orders of ice cream are there? A: 31x4x2=248 Q. What is the total number of subsets of a set A with n elements? That is, |P(A)| = ____? A: Representing each subset of A as a bitstring of length n (A= …1, empty set= ), |P(A)|=2 n.

after UCI ICS/Math 6A, Summer Counting-3 Counting Examples: Sum Rule Q: There is one position available for a faculty job at Irvine. The applicant must come from either Berkeley which has 20 candidates or UCLA which has 50 candidates. What is the total number of possible candidates for the position? A: The applicant must be from Berkeley OR UCLA. So we have 20+50=70 possible applicants. Q: At a resaurant, there are 18 dinners with meat, 10 different dinners with fish, and 5 vegetarian dinners? How many dinners to choose from? A: Each dinner is meat OR fish OR vegetarian. So we have =33 choices.

after UCI ICS/Math 6A, Summer Counting-4 Counting Examples: Mixed Sum and Product Passwords consist of character strings of 6 to 8 characters. Each character is an upper case letter or a digit. Each password must contain at least one digit. How many passwords are possible? Total number is # passwords with 6 char. + # passwords with 7 char. + # pws 8 char. (=P6+P7+P8). P6: # possibilities without constraint : 36 6 # exclusions is # passwords without any digits is 26 6 And so, P6 = Similarly, P7 = and P8 = Giving a final answer of P = P6+P7+P8 =

after UCI ICS/Math 6A, Summer Counting-5 Counting: Inclusion–Exclusion Principle Inclusion-Exclusion Principle: Assuming a)We need to perform procedure 1 OR procedure 2. b)There are n 1 ways to perform procedure 1 and c)n 2 ways to perform procedure 2 and d)m of the ways of doing procedures 1 and 2 are equivalent There are (n 1 + n 2 – m) ways to perform procedure 1 OR procedure 2. (Recall: |A  B| = |A| + |B| - |A  B| )

after UCI ICS/Math 6A, Summer Counting-6 Counting Examples: Inclusion-Exclusion How many bit-strings of length 8 either begin with 1 or end with 00? A = 8-bit strings starting with 1 B = 8-bit strings starting with 00 What’s |A  B| ? It’s |A| + |B| - |A  B|: |A| = # of 8-bit strings starting with 1 is 2 7 |B| = # of 8-bit strings ending with 00 is 2 6 | A  B| = # of 8-bit strings starting with 1 and ending with 00 is 2 5 Final Answer: |A  B| = = |A| + |B| - |A  B|

after UCI ICS/Math 6A, Summer Counting-7 Tree Diagrams Use “tree diagrams” to organize (irregular) counting. How many bit strings of length 4 do not have two consecutive 1’s?

after UCI ICS/Math 6A, Summer Counting-8 Counting: Pigeonhole Principles Pigeonhole Principle: If we have n>k balls and we divide them among k boxes, then at least one box contains 2 balls. Generalized Pigeonhole Principle: If we have n>k balls and we divide them among k boxes, then at least one box contains at least  n/k  balls. Example: k=5, n=11  11/5  =3

after UCI ICS/Math 6A, Summer Counting-9 Proof of Generalized Pigeonhole Principle Claim: If # boxes = k and # balls = n then at least one box contains at least  n/k  balls. Proof by Contradiction: Let us assume that PGG is not true, i.e.: (┐PGG): Each box has at most (  n/k  - 1) balls So the total number of balls is at most k * (  n/k  - 1) Since  n/k  < n/k + 1, we have: # balls (=n) is at most k*(  n/k  - 1) < k*(n/k) = n. In other words, n < n, which is False! So assumption (┐PGG) leads to False. Therefore (┐PGG) is False. Therefore PGG is true.

after UCI ICS/Math 6A, Summer Counting-10 Examples for Generalized Pigeonhole Principle 1. In a group of 366 people there are at least 2 people who have their birthday on the same day.  366/365  = We have 5 possible grades: A,B,C,D,E. How many students do we need to be sure at least 6 get the same grade? Try to fill the boxes evenly: If we have 25 students, then we can have 5 A’s, 5 B’s etc. So if we have 26 students, we need to add a student to some grade, and this grade will then have 6 students. Check:  26 / 5  = 6, but  25 / 5  = 5

after UCI ICS/Math 6A, Summer Counting-11 Example (“reverse PP”): Counting Connections Suppose we have 15 workstations and n=10 servers. Each server can handle only 1 workstation at a time. How many connections are needed s.t. any collection of 10 workstations can simultaneously access a server? k=60 connections suffice. Give each of the first 10 workstations a connection to its own server. Connect each of the remaining 5 to all 10 servers. Why does this work? k=59 connections are not enough. With 59 connections, at least 1 server (“S”) has at most 5 connections (This is “reverse pigeonhole”: k=10 boxes, n=59 balls, one box has ≤ n/k) Those 10 (or more) workstations not connected to S must be served by the 9 remaining servers. OUCH!

after UCI ICS/Math 6A, Summer Counting-12 Counting Friends and Enemies If among a group of 6 people, every pair of persons is either an enemy or a friend, then there are at least 3 mutual friends or 3 mutual enemies. Proof: 1) Any person, A, has, from among the other 5 people, either (at least) 3 friends or (at least) 3 enemies of the 5. Why? 2) Assume “Without Loss Of Generality” (“wlog”), that A has (at least) 3 friends. 3) Either these 3 friends of A are all each others’ enemies (iwc* we are done) or at least 2 of them are (mutual) friends of each other, making A and them a trio of friends (iwc* we are done). * iwc = In Which Case

after UCI ICS/Math 6A, Summer Counting-13 Monotone Sequences Every sequence of n 2 +1 distinct numbers contains a subsequence of n+1 numbers which is either strictly increasing or strictly decreasing. Example: “4,2,5,3,7” contains “4,5,7” Proof: Using a(k) to designate the k th term in the sequence, 1≤k≤n 2 +1 Let I(k) = length of longest increasing sequence starting at a(k) and D(k) = length of longest decreasing sequence starting at a(k).  j ( Unless the result is true,  j ((1≤j≤n 2 +1)  (1≤I(j),D(j)≤n)) Since n 2 <n 2 +1,  j,k ( (1≤j<k≤n 2 +1)  (I(j),D(j)=(I(k),D(k) ) Now, eiither a(j)<a(k) or a(k)<a(j). If a(j)<a(k), adding a(j) to the beginning of the increasing sequence of length I(k) starting at a(k) produces an increasing sequence of length 1+I(k)=1+I(j) starting at a(j). Ouch! If a(k)<a(j), adding a(j) to the begining of the decreasing sequence of length D(k) starting at a(k) produces an decreasing sequence of length 1+D(k)=1+D(j) starting at a(j). Ouch!