Permutations and Combinations

Similar documents
Permutations and Combinations

Discrete Structures Lecture Permutations and Combinations

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

Section Summary. Permutations Combinations Combinatorial Proofs

With Question/Answer Animations. Chapter 6

Sec$on Summary. Permutations Combinations Combinatorial Proofs

Board Question 1. There are 5 Competitors in 100m final. How many ways can gold silver and bronze be awarded? May 27, / 28

Exercises Exercises. 1. List all the permutations of {a, b, c}. 2. How many different permutations are there of the set {a, b, c, d, e, f, g}?

Discrete Mathematics: Logic. Discrete Mathematics: Lecture 15: Counting

Counting. Chapter 6. With Question/Answer Animations

CPCS 222 Discrete Structures I Counting

Topics to be covered

Foundations of Computing Discrete Mathematics Solutions to exercises for week 12

Math 166: Topics in Contemporary Mathematics II

Sec.on Summary. The Product Rule The Sum Rule The Subtraction Rule (Principle of Inclusion- Exclusion)

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

CSCI FOUNDATIONS OF COMPUTER SCIENCE

Combinatorial Proofs

COUNTING AND PROBABILITY

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

CS100: DISCRETE STRUCTURES. Lecture 8 Counting - CH6

Theory of Probability - Brett Bernstein

CS1800: Permutations & Combinations. Professor Kevin Gold

If a regular six-sided die is rolled, the possible outcomes can be listed as {1, 2, 3, 4, 5, 6} there are 6 outcomes.

EECS 203 Spring 2016 Lecture 15 Page 1 of 6

Chapter 2. Permutations and Combinations

Sec 5.1 The Basics of Counting

Combinatorics: The Fine Art of Counting

Counting and Probability Math 2320

Introductory Probability

Course Learning Outcomes for Unit V

Jong C. Park Computer Science Division, KAIST

With Question/Answer Animations. Chapter 6

Section : Combinations and Permutations

W = {Carrie (U)nderwood, Kelly (C)larkson, Chris (D)aughtry, Fantasia (B)arrino, and Clay (A)iken}

Learning Objectives for Section 7.4 Permutations and Combinations. 7.4 Permutations and Combinations

Mat 344F challenge set #2 Solutions

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

Chapter Permutations and Combinations. Section 4 Permutations and Combinations. Example. Definition of n Factorial (n!)

MATH 2420 Discrete Mathematics Lecture notes

Finite Math - Fall 2016

A Probability Work Sheet

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

The next several lectures will be concerned with probability theory. We will aim to make sense of statements such as the following:

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

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

Solutions for Exam I, Math 10120, Fall 2016

Using a table: regular fine micro. red. green. The number of pens possible is the number of cells in the table: 3 2.

Section 6.1 #16. Question: What is the probability that a five-card poker hand contains a flush, that is, five cards of the same suit?

Probability and Counting Techniques

CISC 1400 Discrete Structures

Permutations and Combinations. Quantitative Aptitude & Business Statistics

Independent Events. If we were to flip a coin, each time we flip that coin the chance of it landing on heads or tails will always remain the same.

MATH 215 DISCRETE MATHEMATICS INSTRUCTOR: P. WENG

3 The multiplication rule/miscellaneous counting problems

CHAPTER 2 PROBABILITY. 2.1 Sample Space. 2.2 Events

Well, there are 6 possible pairs: AB, AC, AD, BC, BD, and CD. This is the binomial coefficient s job. The answer we want is abbreviated ( 4

Elementary Combinatorics

Discrete mathematics

PS 3.8 Probability Concepts Permutations & Combinations

Permutations and Combinations Section

Permutations. 1) How many unique 3 digit codes can be created from the 5 digits {1, 2, 3, 4, 5} if repeats are possible?

{ a, b }, { a, c }, { b, c }

Finite Math Section 6_4 Solutions and Hints

Elementary Combinatorics CE 311S

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

13.3 Permutations and Combinations

CHAPTER 5 BASIC CONCEPTS OF PERMUTATIONS AND COMBINATIONS

Counting and Probability

CS 237: Probability in Computing

More Probability: Poker Hands and some issues in Counting

CSE 21 Mathematics for Algorithm and System Analysis

MA 524 Midterm Solutions October 16, 2018

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

Chapter 3: Elements of Chance: Probability Methods

CS1800: More Counting. Professor Kevin Gold

Counting in Algorithms

Probability. The MEnTe Program Math Enrichment through Technology. Title V East Los Angeles College

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

Section Introduction to Sets

Mathematical Foundations HW 5 By 11:59pm, 12 Dec, 2015

1. An office building contains 27 floors and has 37 offices on each floor. How many offices are in the building?

Compound Probability. Set Theory. Basic Definitions

3 The multiplication rule/miscellaneous counting problems

JIGSAW ACTIVITY, TASK # Make sure your answer in written in the correct order. Highest powers of x should come first, down to the lowest powers.

STAT 430/510 Probability Lecture 1: Counting-1

Permutations and Combinations

Name: Exam 1. September 14, 2017

LAMC Junior Circle January 22, Oleg Gleizer. The Hanoi Tower. Part 2

Generalized Permutations and The Multinomial Theorem

CH 13. Probability and Data Analysis

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Counting Methods and Probability

Examples: Experiment Sample space

Math 42, Discrete Mathematics

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

CS 237 Fall 2018, Homework SOLUTION

Section 5.4 Permutations and Combinations

CSE 312: Foundations of Computing II Quiz Section #2: Combinations, Counting Tricks (solutions)

Lecture 14. What s to come? Probability. A bag contains:

Transcription:

Permutations and Combinations Rosen, Chapter 5.3 Motivating question In a family of 3, how many ways can we arrange the members of the family in a line for a photograph? 1

Permutations A permutation of a set of distinct objects is an ordered arrangement of these objects. Example: (1, 3, 2, 4) is a permutation of the numbers 1, 2, 3, 4 How many permutations of n objects are there? How many permutations? How many permutations of n objects are there? Using the product rule: n. (n 1). (n 2),, 2. 1 = n! 2

Anagrams Anagram: a word, phrase, or name formed by rearranging the letters of another. Examples: cinema is an anagram of iceman "Tom Marvolo Riddle" = "I am Lord Voldemort The anagram server: http://wordsmith.org/anagram/ Example How many ways can we arrange 4 students in a line for a picture? 3

Example How many ways can we arrange 4 students in a line for a picture? 4 possibilities for the first position, 3 for the second, 2 for the third, 1 for the fourth. 4*3*2*1 = 24 Example How many ways can we select 3 students from a group of 5 students to stand in line for a picture? 4

Example How many ways can we select 3 students from a group of 5 students to stand in line for a picture? 5 possibilities for the first person, 4 possibilities for the second, 3 for the third. 5*4*3 = 60 Definitions permutation a permutation of a set of distinct objects is an ordered arrangement of these objects. r-permutation a ordered arrangement of r elements of a set of objects. 5

Iclicker Question #1 You invite 4 people for a dinner party. How many different ways can they arrive assuming they enter separately? A) 6 (3!) B) 24 (4!) C) 120 (5!) D) 16 (n 2 ) E) 32 (2n 2 ) Iclicker Question #1 Answer You invite 4 people for a dinner party. How many different ways can they arrive assuming they enter separately? A) 6 (3!) B) 24 (4!) C) 120 (5!) D) 16 (n 2 ) E) 32 (2n 2 ) 6

Example In how many ways can a photographer at a wedding arrange six people in a row, (including the bride and groom)? Example In how many ways can a photographer at a wedding arrange six people in a row, (including the bride and groom)? 6! = 720 7

IClicker Question #2 In how many ways can a photographer at a wedding arrange six people in a row, including the bride and groom, if the bride must be next to the groom? A. 6! B. 5! C. 2X5! D. 2X6! E. 6! 5! IClicker Question #2 In how many ways can a photographer at a wedding arrange six people in a row, including the bride and groom, if the bride must be next to the groom? A. 6! B. 5! C. 2X5! D. 2X6! E. 6! 5! 8

IClicker Question #2 Answer In how many ways can a photographer at a wedding arrange six people in a row, including the bride and groom, if the bride must be next to the groom? Why? The bride and groom become a single unit which can be ordered 2 ways. IClicker Question #3 In how many ways can a photographer at a wedding arrange six people in a row, including the bride and groom, if the bride is not next to the groom? A. 6! B. 2X5! C. 2X6! D. 6! 5! E. 6! 2*5! 9

IClicker Question #3 Answer In how many ways can a photographer at a wedding arrange six people in a row, including the bride and groom, if the bride is not next to the groom? A. 6! B. 2X5! C. 2X6! D. 6! 5! E. 6! 2*5! IClicker Question #3 Answer In how many ways can a photographer at a wedding arrange six people in a row, including the bride and groom, if the bride is not next to the groom? Why? 6! possible ways for 6 2*5! - possible ways the bride is next to the groom. 10

Example In how many ways can a photographer at a wedding arrange six people in a row, including the bride and groom, if the bride s mother is positioned somewhere to the left of the groom? Example In how many ways can a photographer at a wedding arrange six people in a row, including the bride and groom, if the bride s mother is positioned somewhere to the left of the groom? 5! + (4 4!) + (3 4!) + (2 4!) + (1 4!) = 120 + 96 + 72 + 48 + 24 = 360 possible photo arrangements in which the bride s mother is to the left of the groom. 11

Example The first position to fill is the position of the groom. At each position, the bride s mother can only occupy 1 of the slots to the left, the other 4 can be arranged in any manner. 5! + (4 4!) + (3 4!) + (2 4!) + (1 4!) = 120 + 96 + 72 + 48 + 24 = 360 possible photo arrangements in which the bride s mother is to the left of the groom. Example 12

Iclicker Question #4 Count the number of ways to arrange n men and n women in a line so that no two men are next to each other and no two women are next to each other. A. n! B. 2 * n! C. n! * n! D. 2 * n! * n! Iclicker Question Answer #4 Count the number of ways to arrange n men and n women in a line so that no two men are next to each other and no two women are next to each other. A. n! B. 2 * n! C. n! * n! D. 2 * n! * n! 13

Why? Count the number of ways to arrange n men and n women in a line so that no two men are next to each other and no two women are next to each other. n! ways of representing men (n!) n! ways of representing women (n! * n!) Can start with either a man or a woman (x2) So 2*n!*n! The Traveling Salesman Problem (TSP) TSP: Given a list of cities and their pairwise distances, find a shortest possible tour that visits each city exactly once. Objective: find a permutation a 1,,a n of the cities that minimizes where d(i, j) is the distance between cities i and j An optimal TSP tour through Germany s 15 largest cities 14

Solving TSP Go through all permutations of cities, and evaluate the sum-of-distances, keeping the optimal tour. Need a method for generating all permutations Note: how many solutions to a TSP problem with n cities? Generating Permutations Let's design a recursive algorithm for generating all permutations of {0,1,2,,n-1}. 15

Generating Permutations Let's design a recursive algorithm for generating all permutations of {0,1,2,,n-1}. Starting point: decide which element to put first what needs to be done next? what is the base case? Solving TSP Is our algorithm for TSP that considers all permutations of n-1 elements a feasible one for solving TSP problems with hundreds or thousands of cities? 16

r-permutations An ordered arrangement of r elements of a set: number of r-permutations of a set with n elements: P(n,r) Example: List the 2-permutations of {a,b,c}. (a,b), (a,c), (b,a), (b,c), (c,a), (c,b) P(3,2) = 3 x 2 = 6 The number of r-permutations of a set of n elements: then there are P(n,r) = n(n 1) (n r + 1) (0 r n) Can be expressed as: P(n, r) = n! / (n r)! Note that P(n, 0) = 1. Iclicker Question #5 How many ways are there to select a first prize winner, a second prize winner, and a third prize winner from 100 different people who have entered a contest. A. 100! / 97! B. 100! C. 97! D. 100! 97! E. 100-99-98 17

Iclicker Question #5 Answer How many ways are there to select a first prize winner, a second prize winner, and a third prize winner from 100 different people who have entered a contest. A. 100! / 97! B. 100! C. 97! D. 100! 97! E. 100-99-98 Iclicker Question #1 How many permutations of the letters ABCDEFGH contain the string ABC A. 6! B. 7! C. 8! D. 8!/5! E. 8!/6! 18

Iclicker Question #1 Answer How many permutations of the letters ABCDEFGH contain the string ABC A. 6! B. 7! C. 8! D. 8!/5! E. 8!/6! Iclicker Question #1 Answer How many permutations of the letters ABCDEFGH contain the string ABC Why? For the string ABC to appear, it can be treated as a single entity. That means there are 6 entities ABC, D, E, F, G, H. 19

Iclicker Question #2 Suppose there are 8 runners in a race. The winner receives a gold medal, the 2 nd place finisher a silver medal, 3 rd place a bronze, 4 th place a wooden medal. How many possible ways are there to award these medals? A. 5! B. 7! C. 8! / 4! D. 8! / 5! E. 8! / 6! Iclicker Question #2 Answer Suppose there are 8 runners in a race. The winner receives a gold medal, the 2 nd place finisher a silver medal, 3 rd place a bronze, 4 th place a wooden medal. How many possible ways are there to award these medals? A. 5! B. 7! C. 8! / 4! P(8,4) = 8!/(8-4)! = 8 * 7 * 6 * 5 D. 8! / 5! E. 8! / 6! 20

Combinations How many poker hands (five cards) can be dealt from a deck of 52 cards? How is this different than r-permutations? In an r-permutation we cared about order. In this case we don t Combinations An r-combination of a set is a subset of size r The number of r-combinations out of a set with n elements is denoted as C(n,r) or {1,3,4} is a 3-combination of {1,2,3,4} How many 2-combinations of {a,b,c,d}? 21

r-combinations How many r-combinations? Note that C(n, 0) = 1 C(n,r) satisfies: We can see that easily without using the formula Unordered versus ordered selections Two ordered selections are the same if the elements chosen are the same; the elements chosen are in the same order. Ordered selections: r-permutations. Two unordered selections are the same if the elements chosen are the same. (regardless of the order in which the elements are chosen) Unordered selections: r-combinations. 44 22

Relationship between P(n,r) and C(n,r) Suppose we want to compute P(n,r). Constructing an r-permutation from a set of n elements can be thought as a 2-step process: Step 1: Choose a subset of r elements; Step 2: Choose an ordering of the r-element subset. Step 1 can be done in C(n,r) different ways. Step 2 can be done in r! different ways. Based on the multiplication rule, P(n,r) = C(n,r) r! Thus C( n, r) P( n, r) r! n! r! ( n r)! 45 Iclicker Question #3 How many poker hands (five cards) can be dealt from a deck of 52 cards? A. 52! B. 52! / 47! C. (52! 5!) / 47! D. 52! / (5! * 47!) E. (52! 47!) / 5! 23

Iclicker Question #3 Answer How many poker hands (five cards) can be dealt from a deck of 52 cards? A. 52! B. 52! / 47! C. (52! 5!) / 47! D. 52! / (5! * 47!) E. (52! 47!) / 5! Why? There are 52! / 47! Permutations so P(52,5) = 52! 47! Since order doesn t matter, there are 5! solutions that are considered identical. C(52,5) = 52! 5! * 47! 24

Iclicker Question #4 How many committees of 3 students can be formed from a group of 5 students? A. 5! / 2! B. 5! / (2! * 1!) C. 5! / (3! * 2!) D. 6! Iclicker Question #4 Answer How many committees of 3 students can be formed from a group of 5 students? A. 5! / 2! B. 5! / (2! * 1!) C. 5! / (3! * 2!) D. 6! 25

Iclicker Question #5 The faculty in biology and computer science want to develop a program in computational biology. A committee of 4 composed of two biologists and two computer scientists is tasked with doing this. How many such committees can be assembled out of 20 CS faculty and 30 biology faculty? A. C(50,4) B. C(600,4) C. C(20,2) + C(30,2) D. C(20,2) / C(30,2) E. C(20,2) * C(30,2) Iclicker Question #5 Answer The faculty in biology and computer science want to develop a program in computational biology. A committee of 4 composed of two biologists and two computer scientists is tasked with doing this. How many such committees can be assembled out of 20 CS faculty and 30 biology faculty? A. C(50,4) B. C(600,4) C. C(20,2) + C(30,2) D. C(20,2) / C(30,2) E. C(20,2) * C(30,2) 26

Why? There are C(20,2) combinations of CS There are C(30,2) combinations of Biology Using the product rule the total combinations is: C(20,2) * C(30,2) IClicker Question #6 A coin is flipped 10 times, producing either heads or tails. How many possible outcomes are there in total? A. 20 B. 2 10 C. 10 D. 2 10 /4 E. 2 27

IClicker Question #6 Answer A coin is flipped 10 times, producing either heads or tails. How many possible outcomes are there in total? A. 20 B. 2 10 C. 10 D. 2 10 /4 E. 2 IClicker Question #7 A coin is flipped 10 times, producing either heads or tails. How many possible outcomes contain exactly two heads? A. 2 8 B. 2 2 C. 2 10 /(2 8 X 2 2 ) D. 10!/(2! X 8!) E. 10!/2! 28

IClicker Question #7 Answer A coin is flipped 10 times, producing either heads or tails. How many possible outcomes contain exactly two heads? A. 2 8 B. 2 2 C. 2 10 /(2 8 X 2 2 ) D. 10!/(2! X 8!) E. 10!/2! IClicker Question #8 A coin is flipped 10 times, producing either heads or tails. How many possible outcomes contain at most 3 tails? A. 45 B. 175 C. 176 D. 251 E. 252 29

IClicker Question #8 Answer A coin is flipped 10 times, producing either heads or tails. How many possible outcomes contain at most 3 tails? A. 45 B. 175 C. 176 D. 251 E. 252 IClicker Question #8 Answer A coin is flipped 10 times, producing either heads or tails. How many possible outcomes contain at most 3 tails? 1 way for 0 tails 10 ways for 1 tail 10!/2!*8! = 90/2 = 45 ways for 2 tails 10!/3!*7! = 720/6 = 120 ways for 3 tails 30

IClicker Question #9 A coin is flipped 10 times, producing either heads or tails. How many possible outcomes contain the same number of heads and tails? A. 2 10 / 2 B. 10! / (5! X 5!) C. 10! / 5! D. 10 / 5 IClicker Question #9 Answer A coin is flipped 10 times, producing either heads or tails. How many possible outcomes contain the same number of heads and tails? A. 2 10 / 2 B. 10! / (5! X 5!) C. 10! / 5! D. 10 / 5 31

Spock s Dilemma While commanding the Enterprise, Spock has 10 possible planets. He needs you to write a program that allows him to know how many possible combinations there are if he can only visit 4 of the planets. He has become fascinated with recursion and wants you to solve it recursively. How can we do this? Computing C(n, k) recursively consider the nth object C(n,k) = C(n-1,k-1) + C(n-1,k) pick n or don't 32

C(n, k): base case C(k, k) = 1 Why? C(n, 0) = 1 Why? Computing C(n, k) recursively C(n,k) = C(n-1,k-1) + C(n-1,k) pick n or don't C(k,k) = 1 C(n,0) = 1 we can easily code this as a recursive method! This is an example of a recurrence relation, which is a recursive mathematical expression 33

Some Advice about Counting Apply the multiplication rule if The elements to be counted can be obtained through a multistep selection process. Each step is performed in a fixed number of ways regardless of how preceding steps were performed. Apply the addition rule if The set of elements to be counted can be broken up into disjoint subsets Apply the inclusion/exclusion rule if It is simple to over-count and then to subtract duplicates 67 Some more advice about Counting Make sure that 1) every element is counted; 2) no element is counted more than once. (avoid double counting) When using the addition rule: 1) every outcome should be in some subset; 2) the subsets should be disjoint; if they are not, subtract the overlaps 68 34