CS 15-251 Lecture 6 How To Count Without Counting.

Slides:



Advertisements
Similar presentations
Copyright © Cengage Learning. All rights reserved. 6 Sets and Counting.
Advertisements

Counting I: Choice Trees and Correspondences Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 7Sep 14,
Decisions, Decisions, Decisions
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 15 Chances, Probabilities, and Odds 15.1Random Experiments and.
Great Theoretical Ideas in Computer Science.
CSCE 2100: Computing Foundations 1 Combinatorics Tamara Schneider Summer 2013.
Math 221 Integrated Learning System Week 2, Lecture 1
Counting (Combinatorics) 1.
Counting Techniques: Combinations
Discrete Structures & Algorithms Counting Counting I: One-To-One Correspondence and Choice Trees.
Discrete Structures & Algorithms More Counting. + + ( ) + ( ) = ? Counting II: Recurring Problems and Correspondences.
Great Theoretical Ideas in Computer Science.
Counting II: Recurring Problems And Correspondences Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2004 Lecture 10Feb 12, 2004Carnegie.
Discrete Structures Chapter 5 Relations and Functions Nurul Amelina Nasharuddin Multimedia Department.
Counting I: One To One Correspondence and Choice Trees Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2004 Lecture 9Feb 10,
Lecture 3 Set Operations & Set Functions. Recap Set: unordered collection of objects Equal sets have the same elements Subset: elements in A are also.
4/5/05Tucker, Sec Applied Combinatorics, 4rth Ed. Alan Tucker Section 5.4 Distributions Prepared by Jo Ellis-Monaghan.
1 Section 1.8 Functions. 2 Loose Definition Mapping of each element of one set onto some element of another set –each element of 1st set must map to something,
Tucker, Section 5.41 Section 5.4 Distributions By Colleen Raimondi.
6-7 Permutations & Combinations M11.E.3.2.1: Determine the number of permutations and/or combinations or apply the fundamental counting principle.
CompSci 102 Discrete Math for Computer Science March 22, 2012 Prof. Rodger Lecture adapted from Bruce Maggs/Lecture developed at Carnegie Mellon, primarily.
Permutations and Combinations. Random Things to Know.
Elementary Counting Techniques & Combinatorics Martina Litschmannová K210.
4. Counting 4.1 The Basic of Counting Basic Counting Principles Example 1 suppose that either a member of the faculty or a student in the department is.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Combinatorics.
Combinatorics 3/15 and 3/ Counting A restaurant offers the following menu: Main CourseVegetablesBeverage BeefPotatoesMilk HamGreen BeansCoffee.
Basic Counting Lecture 12: Oct 28. This Lecture We will study some basic rules for counting. Sum rule, product rule, generalized product rule Permutations,
Finding Probability Using Tree Diagrams and Outcome Tables
Basic Counting. This Lecture We will study some basic rules for counting. Sum rule, product rule, generalized product rule Permutations, combinations.
Fall 2002CMSC Discrete Structures1 One, two, three, we’re… Counting.
Great Theoretical Ideas in Computer Science.
Permutations, Combinations, and Counting Theory AII.12 The student will compute and distinguish between permutations and combinations and use technology.
1 CSC 321: Data Structures Fall 2013 Counting and problem solving  mappings, bijection rule  sequences, product rule, sum rule  generalized product.
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Copyright  The McGraw-Hill Companies, Inc. Permission required for reproduction.
COMPSCI 102 Discrete Mathematics for Computer Science.
Discrete Mathematics for Computer Science. + + ( ) + ( ) = ? Counting II: Recurring Problems and Correspondences Chapter 9 slides 1-54.
Great Theoretical Ideas in Computer Science.
Unit 2 - Permutations and Organized Counting
COMPSCI 102 Discrete Mathematics for Computer Science.
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,
Basic Structures: Sets, Functions, Sequences, and Sums.
CompSci 102 Discrete Math for Computer Science March 20, 2012 Prof. Rodger Lecture adapted from Bruce Maggs/Lecture developed at Carnegie Mellon, primarily.
Discrete Mathematics, 1st Edition Kevin Ferland Chapter 6 Basic Counting 1.
Counting II: Recurring Problems And Correspondences Great Theoretical Ideas In Computer Science John LaffertyCS Fall 2005 Lecture 7Sept 20, 2005Carnegie.
Counting I: One To One Correspondence and Choice Trees Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2004 Lecture 9Feb 10,
1 Melikyan/DM/Fall09 Discrete Mathematics Ch. 7 Functions Instructor: Hayk Melikyan Today we will review sections 7.3, 7.4 and 7.5.
Counting II: Recurring Problems And Correspondences Great Theoretical Ideas In Computer Science V. AdamchikCS Spring 2006 Lecture 6Feb 2, 2005Carnegie.
CS Lecture 8 Developing Your Counting Muscles.
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.
Counting I: One To One Correspondence and Choice Trees Great Theoretical Ideas In Computer Science John LaffertyCS Fall 2005 Lecture 6Sept 15,
EXIT NEXT Click one of the buttons below or press the enter key BACKTOPICSEXIT NEXT Click one of the buttons below or press the enter key BACKTOPICS.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 18.
COUNTING Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.
Introduction to Discrete Mathematics
Developing Your Counting Muscles
CSC 321: Data Structures Fall 2015 Counting and problem solving
COCS DISCRETE STRUCTURES
Counting I: Bijection and Choice Trees
Counting I: One-To-One Correspondence and Choice Trees
Basic Counting.
Permutations and Combinations
One-to-One and Onto, Inverse Functions
Basic Counting Lecture 9: Nov 5, 6.
Counting II: Recurring Problems And Correspondences
Great Theoretical Ideas in Computer Science
Counting Elements of Disjoint Sets: The Addition Rule
Lecture # 18 Types of Functions
Counting II: Recurring Problems And Correspondences
Chapter 11: Further Topics in Algebra
Counting I: Choice Trees and Correspondences
Presentation transcript:

CS Lecture 6 How To Count Without Counting

If I have 14 teeth on the top and 12 teeth on the bottom, how many teeth do I have in all?

Addition Rule Let A and B be two disjoint, finite sets. The size of A  B is the sum of the size of A and the size of B.

Corollary (by induction) Let A 1, A 2, A 3, …, A n be disjoint, finite sets.

Suppose I roll a white die and a black die.

S  Set of all outcomes where the dice show different values.  S  = ? A i  set of outcomes where the black die says i and the white die says something else.

S  Set of all outcomes where the dice show different values.  S  = ? T  set of outcomes where dice agree.

S  Set of all outcomes where the black die shows a smaller number than the white die.  S  = ? A i  set of outcomes where the black die says i and the white die says something larger.

S  Set of all outcomes where the black die shows a smaller number than the white die.  S  = ? T  set of all outcomes where the black die shows a larger number than the white die.  S  +  T  = 30 It is clear by symmetry that  S  =  T . Therefore  S  = 15

It is clear by symmetry that  S  =  T .

Pinning down the idea of symmetry by exhibiting a correspondence. Let’s put each outcome in S in correspondence with an outcome in T by swapping the color of the dice. No two outcomes in S map to the same outcome in T:  S   T . No two outcomes in S map to the same outcome in T:  S    T . Each outcome in T gets mapped to by an outcome in S:  S   T . Each outcome in T gets mapped to by an outcome in S:  S    T .

Let f:AB be a function from a set A to a set B. Let f:A  B be a function from a set A to a set B. f is 1-1 if and only if  x,y  A, x  y  f(x)  f(y) f is onto if and only if  z  B  x  A f(x) = z

Injection Let f:AB be a function from a set A to a set B. Let f:A  B be a function from a set A to a set B. f is 1-1 if and only if  x,y  A, x  y  f(x)  f(y) f is onto if and only if  z  B  x  A f(x) = z Surjection

Let’s restrict our attention to finite sets. AB

 1-1 f:AB  A   B   1-1 f:A  B  A    B  AB

 onto f:AB  A   B   onto f:A  B  A    B  AB

 1-1 onto f:AB  A   B   1-1 onto f:A  B  A    B  AB

AB Bijection

1-1 Onto Correspondence (just “correspondence” for short) AB

Correspondence Principle If two finite sets can be placed into 1-1 onto correspondence, then they have the same size.

Correspondence Principle If two finite sets can be placed into 1-1 onto correspondence, then they have the same size. It’s one of the most important mathematical ideas of all time!

Question: How many n-bit sequences are there?     3.. 1…11111  2 n -1 2 n sequences

S =  a,b,c,d,e  has many subsets.  a ,  a,b ,  a,d,e ,  a,b,c,d,e ,  e , Ø, … The empty set is a set with all the rights and privileges pertaining thereto.

Question: How many subsets can be formed from the elements of an n- element set? abcde  b,c,e 

S =  a 1, a 2, a 3,…, a n  Let b = b 1 b 2 b 3 …b n be a binary sequence. f(b) =  a i | b i =1  f is a 1-1 onto correspondence from n-bit binary sequences to subsets of S

The number of subsets of an n-element set is 2 n.

I own 3 beanies and 2 ties. How many different ways can I dress up in a beanie and a tie?

A restaurant has a menu with 5 appetizers, 6 entrees, 3 salads, and 7 desserts. How many items on the menu? = 21 How many ways to choose a complete meal? 5 * 6 * 3 * 7 = 630

A restaurant has a menu with 5 appetizers, 6 entrees, 3 salads, and 7 desserts. How many ways to order a meal if I might not have some of the courses? 6 * 7 * 4 * 8 = 1344

Leaf Counting Lemma Let T be a depth n tree when each node at depth 0  i  n-1 has P i children. The number of leaves of T is given by: P 0 P 1 P 2 …P n-1

n n-bit sequences

choices for first bit X 2 choices for second bit X 2 choices for third bit … X 2 choices for the n th

We will now combine the correspondence principle with the leaf counting lemma to make an important rule …

Product Rule Suppose that all objects of a certain type can be constructed by a sequence of choices with P 1 possibilities for the first choice, P 2 for the second, and so on. IF 1) Each sequence of choices constructs some object AND 2) Each object has exactly one sequence which constructs it THEN there are P 1 P 2 P 3 …P n objects of that type.

How many different orderings of deck with 52 cards? What type of object are we making? Ordering of a deck Construct an ordering of a deck by a sequence of 52 choices: 52 possible choices for the first card; 51 possible choices for the second card; 50 possible choices for the third card; … 1 possible choice for the 52 cond card.

How many different orderings of deck with 52 cards? By the product rule: 52 * 51 * 50 * … * 3 * 2 * 1 = 52! 52 “factorial” orderings

How many possible different preference lists with n boys on it? n!

A permutation of n objects is an ordering of the objects. The number of permutations of n distinct objects is n!

If 10 horses race, how many orderings of the top three finishers are there? 10 * 9 * 8 = 720

An r permutation of n objects is an ordering of r of those objects The number of r permutations of n objects: n * (n-1) * (n-2) *…* (n-(r-1))

Ordered Versus Unordered From a deck of 52 cards how many ordered pairs can be formed? 52 * 51 How many unordered pairs? 52*51 / 2  divide by overcount Each unordered pair is listed twice on a list of the ordered pairs.

Ordered Versus Unordered From a deck of 52 cards how many ordered 5 card sequences can be formed? 52 * 51 * 50 * 49 * 48 How many orderings of 5 cards? 5! How many unordered 5 card hands? pairs? 52*51*50*49*48 / 5! = 2,598,960

An r combination of n objects is an (unordered) set of r of the n objects. The number of r combinations of n objects: n choose r

The number of subsets of size k that can be formed from an n-element set is:

How many 8 bit sequences have 2 0’s and 6 1’s? Tempting, but incorrect: 8 ways to place first 0 times 7 ways to place second 0 It violates condition 2 of the product rule: Choosing position i for the first 0 and then position j for the second 0 gives the same sequence as choosing position j for the first 0 and position i for the second.

How many 8 bit sequences have 2 0’s and 6 1’s? 1) Choose the set of 2 positions to put the 0’s. The 1’s are forced. 2) Choose the set of 6 positions to put the 1’s. The 0’s are forced.

Symmetry in the formula:

How many hands have at least 3 aces?

How many hands have exactly 3 aces? How many hands have exactly 4 aces? = 4560

4704  4560 At least one of the two counting arguments is not correct.

Four different sequences of choices produce the same hand A  A  A A  K  A  A  A  A K  A  A  A A  K  A  A  A A  K 

Is the other argument correct? How do I avoid fallacious reasoning?

The Sleuth’s Criterion Condition (2) of the product rule: For any object it should be possible to reconstruct the sequence of choices which lead to it.

Sleuth can’t determine which cards came from which choice. A  A  A A  K  A  A  A  A K  A  A  A A  K  A  A  A A  K  1) Choose 3 of 4 aces 2) Choose 2 of the remaining cards A  A  A A  K 

Sleuth reasons: The aces came from the first choice and the non-aces came from the second choice. 1) Choose 3 of 4 aces 2) Choose 2 non-ace cards A  Q  A  A K 

Sleuth reasons: The aces came from the first choice and the non-ace came from the second choice. 1) Choose 4 of 4 aces 2) Choose 1 non-ace A  A  A  A K 

How many shortest routes from A to B? A B

A B A route is any sequence containing 6 D’s and 8 R’s