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

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

Sec 5.1 The Basics of Counting

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

Slide 1 Math 1520, Lecture 13

6.1 Basics of counting

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

Sets. Definition A set is an unordered collection of objects called elements or members of the set.

CS100: DISCRETE STRUCTURES. Lecture 8 Counting - CH6

Mathematical Foundations of Computer Science Lecture Outline August 30, 2018

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

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

With Question/Answer Animations. Chapter 6

Strings. A string is a list of symbols in a particular order.

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

Reading 14 : Counting

8.2 Union, Intersection, and Complement of Events; Odds

Class 8 - Sets (Lecture Notes)

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

CPCS 222 Discrete Structures I Counting

Combinatorics and Intuitive Probability

LESSON 2: THE INCLUSION-EXCLUSION PRINCIPLE

Principles of Counting. Notation for counting elements of sets

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

Counting and Probability Math 2320

Sample Spaces, Events, Probability

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

Counting. Chapter 6. With Question/Answer Animations

Discrete Structures for Computer Science

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

Principle of Inclusion-Exclusion Notes

n! = n(n 1)(n 2) 3 2 1

Define and Diagram Outcomes (Subsets) of the Sample Space (Universal Set)

CSE 21 Mathematics for Algorithm and System Analysis

Combinatorics: The Fine Art of Counting

There are three types of mathematicians. Those who can count and those who can t.

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

Topics to be covered

Math 3012 Applied Combinatorics Lecture 2

( ) = A. 2. Write the following sets using the roster method. 3. Write the following sets using set-builder notation.

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.

Probability. Ms. Weinstein Probability & Statistics

Compound Probability. Set Theory. Basic Definitions

Discrete mathematics

Problem 2A Consider 101 natural numbers not exceeding 200. Prove that at least one of them is divisible by another one.

Sets. Gazihan Alankuş (Based on original slides by Brahim Hnich et al.) August 6, Outline Sets Equality Subset Empty Set Cardinality Power Set

Sets, Venn Diagrams & Counting

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

Chapter 2 Math

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

Probability and Counting Techniques

Cardinality and Bijections

17. Symmetries. Thus, the example above corresponds to the matrix: We shall now look at how permutations relate to trees.

CIS 2033 Lecture 6, Spring 2017

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

Chapter 1. Set Theory

CHAPTER 7 Probability

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

Counting (Enumerative Combinatorics) X. Zhang, Fordham Univ.

CS1802 Week 6: Sets Operations, Product Sum Rule Pigeon Hole Principle (Ch )

Counting in Algorithms

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

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

DVA325 Formal Languages, Automata and Models of Computation (FABER)

Fundamental Counting Principle 2.1 Page 66 [And = *, Or = +]

Section Introduction to Sets

COUNTING AND PROBABILITY


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

Probability (Devore Chapter Two)

CHAPTER 8 Additional Probability Topics

CS1800: More Counting. Professor Kevin Gold

Teacher s Notes. Problem of the Month: Courtney s Collection

PROBABILITY FOR RISK MANAGEMENT. Second Edition

5 Elementary Probability Theory

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

2. Combinatorics: the systematic study of counting. The Basic Principle of Counting (BPC)

Lecture 18 - Counting

Exam Time. Final Exam Review. TR class Monday December 9 12:30 2:30. These review slides and earlier ones found linked to on BlackBoard

CISC 1400 Discrete Structures

An art collector might own a collection of paintings, while a music lover might keep a collection of CDs. Any collection of items can form a set.

TOPOLOGY, LIMITS OF COMPLEX NUMBERS. Contents 1. Topology and limits of complex numbers 1

CS1802 Week 6: Sets Operations, Product Sum Rule Pigeon Hole Principle (Ch )

Counting and Probability

Chapter 2 Basic Counting

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 11

ACTIVITY 6.7 Selecting and Rearranging Things

EECS 203 Spring 2016 Lecture 15 Page 1 of 6

Chapter 5 - Elementary Probability Theory

7.4 Permutations and Combinations

Theory of Probability - Brett Bernstein

Elementary Combinatorics

Combinatorics. Chapter Permutations. Counting Problems

Section 8.1. Sequences and Series

Probability Models. Section 6.2

Southeastern European Regional Programming Contest Bucharest, Romania Vinnytsya, Ukraine October 21, Problem A Concerts

Lecture 2. 1 Nondeterministic Communication Complexity

Chapter 1 Math Set: a collection of objects. For example, the set of whole numbers is W = {0, 1, 2, 3, }

Content. 1 Understanding and analyzing algorithms. 2 Using graphs and graph algorithms

Counting integral solutions

ACHS Math Team Lecture: Introduction to Set Theory Peter S. Simon

Transcription:

What can we count? In how many ways can we paint 6 rooms, choosing from 15 available colors? What if we want all rooms painted with different colors? In how many different ways 10 books can be arranged on a shelf? What if 2 of those 10 books are identical copies? p. 2

1, 2, 5, 14,... p. 3

1, 2, 5, 14,... p. 4

Problem The chairs of an auditorium are to be labeled with an uppercase letter followed by a positive integer not exceeding 100. What is the largest number of chairs that can be labeled differently? A-1, A-2,... Z-100 There are 1. 26 ways to assign a letter and 26 100 2. 100 ways to assign a number. p. 5

Problem The chairs of an auditorium are to be labeled with an uppercase letter followed by a positive integer not exceeding 100. What is the largest number of chairs that can be labeled differently? A-1, A-2,... Z-100 There are 1. 26 ways to assign a letter and 2. 100 ways to assign a number. 26 100 p. 6

There are 1. 26 ways to assign a letter and 2. 100 ways to assign a number. 26 100. Suppose that a procedure can be broken down into a sequence of two tasks. If there are n 1 ways to do the first task and for each of these ways of doing the first task, there are n 2 ways to do the second task, then there are n 1 n 2 ways to do the procedure. p. 7

Chairs again Consider the same problem about the labels for chairs 1. 26 ways to choose a letter and 2. 100 ways to choose a number. Write a program that prints all 2600 labels? for a := A to Z do for n := 1 to 100 do print_label(a, n) p. 8

Chairs again Consider the same problem about the labels for chairs 1. 26 ways to choose a letter and 2. 100 ways to choose a number. Write a program that prints all 2600 labels? for a := A to Z do for n := 1 to 100 do print_label(a, n) p. 9

Generalized Product Rule If a procedure consists of k sub-tasks, and the sub-tasks can be performed in n 1,..., n k ways, then the procedure can be performed in (n 1 n 2... n k ) ways. Example: Count the number of different bit strings of length seven. p. 10

Generalized Product Rule If a procedure consists of k sub-tasks, and the sub-tasks can be performed in n 1,..., n k ways, then the procedure can be performed in (n 1 n 2... n k ) ways. Example: Count the number of different bit strings of length seven. The value for each bit can be chosen in two ways (0 or 1). Therefore: 2 2 2 2 2 2 2 = 2 7 = 128 p. 11

License plates How many different license plates of this format can be made? 1 1, 1 p. 12

License plates How many different license plates of this format can be made? 26 3 10 4 = 175, 760, 000 p. 13

Another counting problem A college library has 40 books on sociology and 50 books on anthropology. You have to choose only one book from the library. In how many ways can it be done? p. 14

Another counting problem A college library has 40 books on sociology and 50 books on anthropology. You have to choose only one book from the library. In how many ways can it be done? 40 + 50 = 90 this is called the rule of sum p. 15

40 books on sociology, and 50 books on anthropology. There are 40 + 50 = 90 ways to choose a book. Write an algorithm for a robot to read all the books in the library: for b := 1 to 40 do r ead(sociology, b) for b := 1 to 50 do r ead(anthropology, b) p. 16

40 books on sociology, and 50 books on anthropology. There are 40 + 50 = 90 ways to choose a book. Write an algorithm for a robot to read all the books in the library: for b := 1 to 40 do r ead(sociology, b) for b := 1 to 50 do r ead(anthropology, b) p. 17

40 books on sociology, and 50 books on anthropology. There are 40 + 50 = 90 ways to choose a book.. If a task can be done either in one of n 1 ways or in one of n 2 ways, where 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. Note that it s important that the two groups don t have common elements (We say that they are disjoint sets). p. 18

Problem You have 3 textbooks, 5 novels, 4 magazines, and 2 comic books. You want to pick only one book to read in the subway. How many options do you have? p. 19

Problem You have 3 textbooks, 5 novels, 4 magazines, and 2 comic books. You want to pick only one book to read in the subway. How many options do you have? 3 + 5 + 4 + 2 = 14. p. 20

Problem NYS whats to change the license plates format, allowing 3 letters + 3 digits; 2 letters + 2 digits; and 1 letter + 1 digit. AAA 111 AA 11 A 1 How many license plates can be made? p. 21

Problem NYS whats to change the license plates format, allowing up to 3 letters followed by up to 3 digits. A 1 A 11 A 111 AA 1 AA 11 AA 111 AAA 1 AAA 11 AAA 111 How many license plates can be made? p. 22

A new object Def. A set is an unordered collection of objects. The objects are called elements. If e is an element of the set A, we write e A. Otherwise, if it s not in A, we write e / A. Example: A = {1, 2, 97, 3, 15}. 1 A. 4 / A. {1, 2, 3, 3, 2, 1, 1, 1, 1} = {1, 2, 3} p. 23

Sets p. 24

Some important sets Natural numbers = {0, 1, 2, 3,...} Integer numbers = {..., 3, 2, 1, 0, 1, 2, 3,...} Empty set = { } p. 25

Set Builder Notation We can describe sets using predicates: A = {x P(x)} Set A is such that x A if and only if P(x). Example. Positive integers: Z + = n n > 0 = {1, 2, 3,...} More complex predicates are fine too. Odd and even numbers: Even = n k (n = 2k) Odd = n k (n = 2k + 1) p. 26

Union, A B denotes all things that are members of either A or B: Equivalently: A B = {x (x A) (x B)} x belongs to A B if and only if x A or x B. Examples: {1, 2} { a, b } = {1, 2, a, b } {1, 2, 3} {2, 3, 5} = {1, 2, 3, 5} p. 27

Intersection, A B denotes all things that are members of both A and B: Equivalently: A B = {x (x A) (x B)} x belongs to A B if and only if x A and x B. Examples: {1, 2} { a, b } = {1, 2, 3} {2, 3, 5} = {2, 3} Sets A and B are called disjoint if their intersection is empty: A B =. p. 28

Number of the elements of a finite set Def. If set A is finite, and there are exactly n elements in S, then n is the cardinality of the set A. We write A = n. Examples: A = {3, 4, 5, 6} A = 4 B = {3, 4}, {5, 6}, 7 B = 3 = 0 p. 29

Question A = {1, 2, 4, 5} B = {20, 21, 22, 23, 24} A B = {1, 2, 4, 5, 20, 21, 22, 23, 24} If two sets are disjoint (their intersection is empty), what is the cardinality if their union? A B = 9, and A + B = 4 + 5 = 9. A B = A + B = 4 + 5 = 9. p. 30

Question A = {1, 2, 4, 5} B = {20, 21, 22, 23, 24} A B = {1, 2, 4, 5, 20, 21, 22, 23, 24} If two sets are disjoint (their intersection is empty), what is the cardinality if their union? A B = 9, and A + B = 4 + 5 = 9. A B = A + B = 4 + 5 = 9. p. 31

Question You are given k disjoint sets A 1,... A k : It means that A i A j = when i j. What is the cardinality if their union A 1... A k? A 1... A k = A 1 +... + A k = This is the same sum rule for counting k A i. i=1 p. 32

Question You are given k disjoint sets A 1,... A k : It means that A i A j = when i j. What is the cardinality if their union A 1... A k? A 1... A k = A 1 +... + A k = This is the same rule of sum, right? k A i. i=1 p. 33

Question You are given k disjoint sets A 1,... A k : It means that A i A j = when i j. What is the cardinality if their union A 1... A k? A 1... A k = A 1 +... + A k = This is the same rule of sum, right? k A i. i=1 p. 34

Question Why do we insist on the sets being disjoint? Really, who cares? p. 35

Because A = {1, 2, 3} B = {3, 4} Their union: A B = {1, 2, 3, 4} A + B = {1, 2, 3} + {3, 4} = 3 + 2 = 5 A B = {1, 2, 3, 4} = 4 So, in general, A B = A + B, and if we try to use the sum rule when the sets are not disjoint, we overcount, and this is really bad. p. 36

A = {1, 2, 3} B = {3, 4} A B = {1, 2, 3, 4} We were overcounting, because the common elements of A and B were counted twice: A + B = {1, 2, 3} + {3, 4} = 5, A B = {1, 2, 3, 4} = 4. Therefore, to get the correct value of A B, the number of common elements must be subtracted: A B = A + B {3} = 3 + 2 1 = 4 p. 37

A = {1, 2, 3} B = {3, 4} A B = {1, 2, 3, 4} We were overcounting, because the common elements of A and B were counted twice: A + B = {1, 2, 3} + {3, 4} = 5, A B = {1, 2, 3, 4} = 4. Therefore, to get the correct value of A B, the number of common elements must be subtracted: A B = A + B {3} = 3 + 2 1 = 4. p. 38

The A = {1, 2, 3} B = {3, 4} A B = {1, 2, 3, 4} Therefore, to get the correct value of A B, the number of common elements must be subtracted: A B = A + B {3} = 3 + 2 1 = 4. The for two arbitrary sets A and B: A B = A + B A B p. 39

The A = {1, 2, 3} B = {3, 4} A B = {1, 2, 3, 4} Therefore, to get the correct value of A B, the number of common elements must be subtracted: A B = A + B {3} = 3 + 2 1 = 4. The for two arbitrary sets A and B: A B = A + B A B p. 40

paths This is a map with three cities, connected by roads. Count the number of paths from city A to city C, such that each city is visited not more than once. p. 41

paths This is a map with three cities, connected by roads. Count the number of paths from city A to city C, such that each city is visited not more than once. A C 2 + 3 4 = 14 p. 42

paths This is a map with three cities, connected by roads. Count the number of paths from city A to city C, such that each city is visited not more than once. A C or A B C: 2 + 3 4 = 14 p. 43

round trips This is a map with three cities, connected by roads. Count the number of round trips starting in city B, such that cities A and C are visited not more than once. B A B 3 3 = 9 B C B 4 4 = 16 B A C B 3 2 4 = 24 B C A B 4 2 3 = 24 Total 73 p. 44

round trips This is a map with three cities, connected by roads. Count the number of round trips starting in city B, such that cities A and C are visited not more than once. B A B 3 3 = 9 B C B 4 4 = 16 B A C B 3 2 4 = 24 B C A B 4 2 3 = 24 Total 73 p. 45

round trips II This is a map with three cities, connected by roads. Count the number of round trips starting in city B, such that 1) cities A and C are visited not more than once, and 2) each road is used not more than once during a trip. B A B 3 2 = 6 B C B 4 3 = 12 B A C B 3 2 4 = 24 B C A B 4 2 3 = 24 Total 66 p. 46

round trips II This is a map with three cities, connected by roads. Count the number of round trips starting in city B, such that 1) cities A and C are visited not more than once, and 2) each road is used not more than once during a trip. B A B 3 2 = 6 B C B 4 3 = 12 B A C B 3 2 4 = 24 B C A B 4 2 3 = 24 Total 66 p. 47

problems can be solved using tree diagrams. Each branch represent one possible choice. Each possible outcome is a leaf of the tree (an endpoint that does not branch). Example: Count all bit strings of length four. 16 strings. p. 48

problems can be solved using tree diagrams. Each branch represent one possible choice. Each possible outcome is a leaf of the tree (an endpoint that does not branch). Example 2: Count all bit strings of length four that do not have two consecutive 1s. 8 strings. p. 49

Ranking cats p. 50

Ranking cats In how many different ways can you rank a set of 6 cats: {a, b, c, d, e, f } There are 6 ways to select the first cat, 5 ways to select the second cat among the remaining five, 4 ways to select the third cat...... continue the process In the end, the only remaining cat takes the last position in the rank. 6 5 4 3 2 1ways p. 51

Ranking cats In how many different ways can you rank a set of 6 cats: {a, b, c, d, e, f } There are 6 ways to select the first cat, 5 ways to select the second cat among the remaining five, 4 ways to select the third cat...... continue the process In the end, the only remaining cat takes the last position in the rank. 6 5 4 3 2 1ways. p. 52

Ranking cats In how many different ways can you rank a set of 6 cats: {a, b, c, d, e, f } There are 6 ways to select the first cat, 5 ways to select the second cat among the remaining five, 4 ways to select the third cat...... continue the process In the end, the only remaining cat takes the last position in the rank. 6 5 4 3 2 1 ways! p. 53

How large this number is? 6 5 4 3 2 1 = 720 This function is called factorial and denoted by n!: 1! = 1 2! = 2 1 3! = 3 2 1 4! = 4 3 2 1 5! = 5 4 3 2 1 6! = 6 5 4 3 2 1 n! = n (n 1) (n 2) (n 3)... 1 and by convention, 0! = 1 p. 54