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.

Slides:



Advertisements
Similar presentations
22C:19 Discrete Math Counting Fall 2011 Sukumar Ghosh.
Advertisements

9.5 Counting Subsets of a Set: Combinations
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.
MAT 103 Probability In this chapter, we will study the topic of probability which is used in many different areas including insurance, science, marketing,
Basic Permutations and Combinations
Basic Counting Rosen 4.1. Sum Rule If a first task can be done in n 1 ways and a second task can be done in n 2 ways, and if these tasks cannot be done.
4.5 Generalized Permutations and Combinations
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.
Counting. Counting = Determining the number of elements of a finite set.
The Pigeonhole Principle
1 Let’s Recapitulate. 2 Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Bottoms Up Factoring. Start with the X-box 3-9 Product Sum
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.
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.
after UCI ICS/Math 6A, Summer Counting-1 Counting: Product and Sum Rules Product Rule: Assuming a)We need to.
College of Information Technology & Design
The Basis of Counting. Imagine you go out for lunch, and as a 1st course you can have soup or pate (but not both) you can have chicken soup or carrot.
Functions, Pigeonhole Principle Lecture 14: Nov 4 A B f( ) =
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.
Recursive Definitions Rosen, 3.4 Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
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.
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
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.
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,
5.2 The Pigeonhole Principle
Discrete Structures Counting (Ch. 6)
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.
CS 104: Discrete Mathematics
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.
Section The Product Rule  Example: How many different license plates can be made if each plate contains a sequence of three uppercase English letters.
COUNTING Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.
Principle of Inclusion and Exclusion
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
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
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
Basic Counting.
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
The Pigeonhole Principle
Presentation transcript:

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 procedure 2. There are n1 ways to perform procedure 1 and n2 ways to perform procedure 2. Then there are n1xn2 ways to perform procedure 1 AND procedure 2. Sum Rule: Assume we need to perform procedure 1 OR procedure 2. There are n1 ways to perform procedure 1 and n2 ways to perform procedure 2. Then there are n1+n2 ways to perform procedure 1 OR procedure 2.

4.1 Counting Examples product rule: 1. We need to label chairs with a letter AND a number between [ ]. What is the number of ways to label a chair?  26 possibilities to assign a letter, and for every letter there are 100 possibilities to assign a number. Total What is the total number of subsets of a set A with n elements? I.e. what is the cardinality of the power-set P(A)?  Recall that we can map A to a bit-string: (n times). Each subset is associated with a bunch of zeros. ( = empty set). Total # subsets therefore 2^n.

4.1 Counting Examples sum rule: 1. There is one position available for a PhD position at Irvine. The student 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.  The candidate must be from Berkeley OR UCLA so we have 20+50=70 possible candidates. 2. There are 3 topics and each topic contains 20 projects. How many projects to choose from: =60.

4.1 Counting Mixed examples: 1. 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. P6 = 36^6-26^6 P7 = 36^7-26^7 P8 = 36^8-26^8 P = P6+P7+P8

4.1 Counting Inclusion – Exclusion Principle: Assume that m out of n1 ways to do procedure 1 are equivalent to m out of n2 ways to do procedure 2. Then the number of ways to perform procedure 1 OR procedure 2 are n1+n2-m. Example: There are 3 topics and 20 projects per topic, but 1 project is listed in all three topics. What is the total number of projects?  – 2 because one project was over-counted twice. Recall: The cardinality of the union set of overlapping sets A, B: Recall Sum Rule: Assume we need to perform procedure 1 OR procedure 2. There are n1 ways to perform procedure 1 and n2 ways to perform procedure 2. Then there are n1+n2 ways to perform procedure 1 OR procedure 2.

4.1 Counting Example: How many bit-strings of length 8 begin with either a 1 or end with 00?  Total number of bit-strings starting with 1 is 2^7. Total number of bit-strings ending with 00 is 2^6 However, out of those 2^6 there are 2^5 bit-strings which stared with a one and were counted in the 2^7 of the first line. Conclusion: 2^7+2^6-2^5.

4.2 Counting 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 balls. k=5, n=11 =3

4.1 Counting Proof: Note that the following is true: ceiling function (e.g. 3 < = 3.1) Therefore: This is the maximal number of balls if none of the boxes contains at least balls. However, this number is smaller than n, which is a contradiction. assume none of the boxes has at least balls.

4.1 Counting Examples: 1. In a group of 370 people there are at least 2 people who have their birthday on the same day. CEILING(370/365)=2. (days in a year = boxes, people is balls) 2. 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 add a student to a grade which then has 6 students. (grades = boxes, students = balls)

4.1 Counting More examples: We have 15 workstations and 10 servers. We want that each subset of the 10 workstations can simultaneously access a server, while a server can only handle one workstation at a time. Prove that the minimal number of connections required is 60.  Assume it is 59. Then one server S* must have at most 5 connections (if all servers had 6 connections we had 60 wires). Assume that the workstations that are not connected to S* (which are 10 in number) are the ones that try to make a connection. However, there are only 9 servers left..... A possible solution is this: connect the first 10 workstations to a unique server, and the remaining 5 to all servers. For any subset of 10 workstations, the uniquely wired workstations connect to their assigned server. The remaining ones pick an unoccupied server, which is always possible because they are connected to all of them.

4.1 Counting At a party of 6 people, every pair of persons is either an enemy or a friend. There are at least 3 mutual friend or 3 mutual enemies at the party. proof: Consider person A: it certainly has either 3 friends or 3 enemies at the party. (pigeonhole principle! 5 people in 2 categories. At least 2 of the same must exist). Assume they are friends. Are these 3 friends of A mutual friends? If they are all enemies: we have a collection of 3 enemies and we are done. If not, then at least 2 must be friends, which makes a group of three friends with A and we are done.