CSE 321 Discrete Structures Winter 2008 Lecture 16 Counting.

Slides:



Advertisements
Similar presentations
Basic Permutations and Combinations
Advertisements

Counting. Counting = Determining the number of elements of a finite set.
1 Section 4.3 Permutations & Combinations. 2 Permutation Set of distinct objects in an ordered arrangement An ordered arrangement of r members of a set.
Permutations and Combinations Rosen 4.3. Permutations A permutation of a set of distinct objects is an ordered arrangement these objects. An ordered arrangement.
Counting Chapter 6 With Question/Answer Animations.
Advanced Counting Techniques Prof. Johnnie Baker
Chapter 6 With Question/Answer Animations. Chapter Summary The Basics of Counting The Pigeonhole Principle Permutations and Combinations Binomial Coefficients.
THE BASIC OF COUNTING Discrete mathematics KNURE, Software department, Ph , N.V. Bilous.
1 Discrete Math CS 2800 Prof. Bart Selman Module Counting Chapter 5, Rosen.
Counting and Probability The outcome of a random process is sure to occur, but impossible to predict. Examples: fair coin tossing, rolling a pair of dice,
CSE115/ENGR160 Discrete Mathematics 04/17/12
Permutations r-permutation (AKA “ordered r-selection”) An ordered arrangement of r elements of a set of n distinct elements. permutation of a set of n.
Lecture 5 Counting 4.3, Permutations r-permutation: An ordered arrangement of r elements of a set of n distinct elements. Example: S={1,2,3}:
Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS Fall 2010 Lecture 8Sept. 16,
Discrete Mathematics Lecture 6 Alexander Bukharovich New York University.
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
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.
Counting Chapter 6 With Question/Answer Animations.
MAT 2720 Discrete Mathematics Section 6.1 Basic Counting Principles
Counting. Why counting  Determine the complexity of algorithms To sort n numbers, how many instructions are executed ?  Count the number of objects.
The Basics of Counting Section 6.1.
Basic Counting. This Lecture We will study some basic rules for counting. Sum rule, product rule, generalized product rule Permutations, combinations.
Chapter The Basics of Counting 5.2 The Pigeonhole Principle
Generalized Permutations and Combinations
Chapter 6 With Question/Answer Animations 1. Chapter Summary The Basics of Counting The Pigeonhole Principle Permutations and Combinations Binomial Coefficients.
Permutations and Combinations
Fall 2002CMSC Discrete Structures1 One, two, three, we’re… Counting.
CSE 221: Algorithms and Data Structures Lecture #10 Counting: Easy as 1, 2, C(3,1) Steve Wolfman 2009W1 1.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
1 Lecture 4 (part 1) Combinatorics Reading: Epp Chp 6.
ICS 253: Discrete Structures I Counting and Applications King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Lecture 5 Counting 4.3, Permutations r-permutation: An ordered arrangement of r elements of a set of n distinct elements. Example: S={1,2,3}:
Simple Arrangements & Selections. Combinations & Permutations A permutation of n distinct objects is an arrangement, or ordering, of the n objects. An.
Counting CSC-2259 Discrete Structures Konstantin Busch - LSU1.
R. Johnsonbaugh Discrete Mathematics 5 th edition, 2001 Chapter 4 Counting methods and the pigeonhole principle.
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,
CS 103 Discrete Structures Lecture 16
Counting.
1 CS 140 Discrete Mathematics Combinatorics And Review Notes.
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.
Copyright © Peter Cappello 2011 Simple Arrangements & Selections.
CS 104: Discrete Mathematics
L14: Permutations, Combinations and Some Review EECS 203: Discrete Mathematics.
Section The Pigeonhole Principle If a flock of 20 pigeons roosts in a set of 19 pigeonholes, one of the pigeonholes must have more than 1 pigeon.
Chapter 6 With Question/Answer Animations Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written.
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 歐亞書局.
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.
Section 6.3. Section Summary Permutations Combinations.
Lec 13 – March 10  The Basics of Counting  The Pigeonhole Principle  Permutations and Combinations  Binomial Coefficients and Identities  Generalized.
MAT 2720 Discrete Mathematics
Discrete Mathematics Counting.
L14: Permutations, Combinations and Some Review
ICS 253: Discrete Structures I
Chapter 5, Section 5.1 The Basics of Counting
COCS DISCRETE STRUCTURES
Permutations and Combinations
Counting Chapter 6 With Question/Answer Animations
CS 2210 Discrete Structures Counting
CS100: Discrete structures
Permutations and Combinations
Basic Counting.
Combinatorics.
CSE 321 Discrete Structures
CSE 321 Discrete Structures
CSE 321 Discrete Structures
Basic Counting Lecture 9: Nov 5, 6.
Presentation transcript:

CSE 321 Discrete Structures Winter 2008 Lecture 16 Counting

Announcements Readings –Friday, Wednesday: Counting –6 th edition: 5.1, 5.2, 5.3, 5 th edition: 4.1, –Lecture 16 video will be posted on Tuesday –Monday, Presidents’ Day, Holiday

Counting Determining the number of elements of a finite set

Counting Rules Product Rule: If there are n 1 choices for the first item and n 2 choices for the second item, then there are n 1 n 2 choices for the two items Sum Rule: If there are n 1 choices of an element from S 1 and n 2 choices of an element from S 2 and S 1  S 2 is empty, then there are n 1 + n 2 choices of an element from S 1  S 2

Counting examples License numbers have the form LLL DDD, how many different license numbers are available? There are 38 students in a class, and 38 chairs, how many different seating arrangements are there if everyone shows up? How many different predicates are there on  = {a,…,z}?

Important cases of the Product Rule Cartesian product –|A 1  A 2  …  A n | = |A 1 ||A 2 |  |A n | Subsets of a set S –|P(S)|= 2 |S| Strings of length n over  –|  n | = |  | n

Counting Functions Suppose |S| = n, |T| = m How many functions from S to T? How many one-to-one functions from S to T?

More complicated counting examples BASIC variable names –Variables can be one or two characters long The first character must be a letter The second character can be a letter or a digit The keywords “TO”, “IF”, and “DO” are excluded

Counting Passwords Passwords must be 4 to 6 characters long, and must contain at least one letter and at least one digit. (Case insensitive, no special characters)

Inclusion-Exclusion Principle How many binary strings of length 9 start with 00 or end with 11 |A 1  A 2 | = |A 1 | + |A 2 | - |A 1  A 2 |

Inclusion-Exclusion A class has of 40 students has 20 CS majors, 15 Math majors. 5 of these students are dual majors. How many students in the class are neither math, nor CS majors?

Generalizing Inclusion Exclusion

Pigeon Hole Principle If k is a positive integer and k+1 or more objects are placed into k boxes, then at least one box has two or more objects If N objects are placed into k boxes, then there is at least one box containing at least  N/k  objects

PHP Applications Prove that if a city has at least 10 million phone subscribers it needs more than one area code. (Phone numbers of the form NXX-XXXX.) Prove that if you have 800 people, at least three share a common birthday.

Clever PHP Applications Every sequence of n distinct numbers contains a subsequence of length n+1 that is either strictly increasing or strictly decreasing. 4, 22, 8, 15, 19, 11, 2, 1, 9, 20, 10, 7, 16, 3, 6, 5, 14

Proof Let a 1,... a m be a sequence of n 2 +1 distinct numbers Let i k be the length of the longest increasing sequence starting at a k Let d k be the length of the longest decreasing sequence starting at a k Suppose i k  n and d k  n for all k There must be k and j, k < j, with i k = i j and d k = d j

Permutations vs. Combinations How many ways are there of selecting 1 st, 2 nd, and 3 rd place from a group of 10 sprinters? How many ways are there of selecting the top three finishers from a group of 10 sprinters?

r-Permutations An r-permutation is an ordered selection of r elements from a set P(n, r), number of r-permutations of an n element set

r-Combinations An r-combination is an unordered selection of r elements from a set (or just a subset of size r) C(r, n), number of r-permutations of an n element set

How many Binary strings of length 10 with 3 0’s Binary strings of length 10 with 7 1’s How many different ways of assigning 38 students to the 5 seats in the front of the class How many different ways of assigning 38 students to a table that seats 5 students

Prove C(n, r) = C(n, n-r) [Proof 1] Proof by formula

Prove C(n, r) = C(n, n-r) [Proof 2] Combinatorial proof

Counting paths How many paths are there of length n+m-2 from the upper left corner to the lower right corner of an n  m grid?

Binomial Theorem

Binomial Coefficient Identities from the Binomial Theorem

Pascal’s Identity and Triangle

How many Let s 1 be a string of length n over   Let s 2 be a string of length m over   Assuming   and   are distinct, how many interleavings are there of s 1 and s 2 ?

Permutations with repetition

Combinations with repetition How many different ways are there of selecting 5 letters from {A, B, C} with repetition

How many non-decreasing sequences of {1,2,3} of length 5 are there?

How many different ways are there of adding 3 non-negative integers together to get 5 ?  |   |     | |   

C(n+r-1,n-1) r-combinations of an n element set with repetition

Permutations of indistinguishable objects How many different strings can be made from reordering the letters ABCDEFGH How many different strings can be made from reordering the letters AAAABBBB How many different strings can be made from reordering the letters GOOOOGLE