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

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

Counting. Chapter 6. With Question/Answer Animations

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}?

CPCS 222 Discrete Structures I Counting

Sec 5.1 The Basics of Counting

CS100: DISCRETE STRUCTURES. Lecture 8 Counting - CH6

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

Topics to be covered

With Question/Answer Animations. Chapter 6

CSCI FOUNDATIONS OF COMPUTER SCIENCE

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

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

Combinatorial Proofs

Section : Combinations and Permutations

COUNTING AND PROBABILITY

Math 166: Topics in Contemporary Mathematics II

Foundations of Computing Discrete Mathematics Solutions to exercises for week 12

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

CS1800: Permutations & Combinations. Professor Kevin Gold

Introductory Probability

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

Jong C. Park Computer Science Division, KAIST

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

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

Course Learning Outcomes for Unit V

Counting in Algorithms

Unit Nine Precalculus Practice Test Probability & Statistics. Name: Period: Date: NON-CALCULATOR SECTION

Finite Math - Fall 2016

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

Elementary Combinatorics

Theory of Probability - Brett Bernstein

CSE 21 Math for Algorithms and Systems Analysis. Lecture 2 Lists Without Repe>>on

Combinatorics: The Fine Art of Counting

Counting and Probability Math 2320

Chapter 2. Permutations and Combinations

EECS 203 Spring 2016 Lecture 15 Page 1 of 6

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

3 The multiplication rule/miscellaneous counting problems

Mat 344F challenge set #2 Solutions

CS 237: Probability in Computing

Permutations and Combinations Section

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

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

MATH 215 DISCRETE MATHEMATICS INSTRUCTOR: P. WENG

Permutations and Combinations. Quantitative Aptitude & Business Statistics

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

Elementary Combinatorics CE 311S

CISC 1400 Discrete Structures

CS1800: More Counting. Professor Kevin Gold

Probability and Counting Techniques

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

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

Math 42, Discrete Mathematics

CHAPTER 5 BASIC CONCEPTS OF PERMUTATIONS AND COMBINATIONS

MA 524 Midterm Solutions October 16, 2018

CSE 21 Mathematics for Algorithm and System Analysis

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

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

Discrete mathematics

3 The multiplication rule/miscellaneous counting problems

Counting Methods and Probability

Section 5.4 Permutations and Combinations

MATH 2420 Discrete Mathematics Lecture notes

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

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

Section 5.4 Permutations and Combinations

Reading 14 : Counting

Multiple Choice Questions for Review

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 Theory. Mohamed I. Riffi. Islamic University of Gaza

Permutations and Combinations

aabb abab abba baab baba bbaa permutations of these. But, there is a lot of duplicity in this list, each distinct word (such as 6! 3!2!1!

Fundamental Counting Principle

DISCRETE STRUCTURES COUNTING

6.1 Basics of counting

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

A Probability Work Sheet

Week 3-4: Permutations and Combinations

Chapter 4: Introduction to Probability

Name: Exam 1. September 14, 2017

Section 6.4 Permutations and Combinations: Part 1

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

Counting Things. Tom Davis March 17, 2006

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

Simple Counting Problems

Chapter 3: Elements of Chance: Probability Methods

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

Finite Math Section 6_4 Solutions and Hints

CHAPTER 2 PROBABILITY. 2.1 Sample Space. 2.2 Events

1 = 3 2 = 3 ( ) = = = 33( ) 98 = = =

Combinational Mathematics - I

Counting and Probability

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

Discrete Mathematics with Applications MATH236

Transcription:

Motivating question Permutations and Combinations A) Rosen, Chapter 5.3 B) C) D) Permutations A permutation of a set of distinct objects is an ordered arrangement of these objects. : (1, 3, 2, 4) is a permutation of the numbers 1, 2, 3, 4 How many permutations of n objects are there? In a family of 3, how many ways are there to arrange the members of the family in a line for a photograph? 3x3 3! 3x3x3 23 How many permutations? How many permutations of n objects are there? Using the product rule: n.(n 1). (n 2),, 2. 1 = n!

Anagrams Anagram: a word, phrase, or name formed by rearranging the letters of another. s: cinema is an anagram of iceman "Tom Marvolo Riddle" = "I am Lord Voldemort 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) n! n! c) 2 n! n! The anagram server: http://wordsmith.org/anagram/ You invite 6 people for a dinner party. How many ways are there to seat them around a round table? (Consider two seatings to be the same if everyone has the same left and right neighbors). In how many ways can a photographer at a wedding arrange six people in a row, including the bride and groom, if A) B) C) 6! 5! 7! the bride must be next to the groom? The bride is not next to the groom? The bride is positioned somewhere to the left of the groom?

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 a1,,an of the cities that minimizes where d(i, j) is the distance between cities i and j Go through all permutations of cities, and evaluate the sum-of-distances, keeping the optimal tour. Do we actually need to consider all permutations of n cities? An optimal TSP tour through Germany s 15 largest cities Generating Permutations Solving TSP Let's design a recursive algorithm for generating all permutations of {1,2,,n}. Generating Permutations Let's design a recursive algorithm for generating all permutations of {1,2,,n}. 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? r-permutations - example How many ways are there to select a firstprize winner, a second prize winner and a third prize winner from 100 people who have entered a contest? r-permutations r-permutation: An ordered arrangement of r elements of a set. : List the 2-permutations of {a,b,c}. (a,b), (a,c), (b,a), (b,c), (c,a), (c,b) The number of r-permutations of a set of n elements: P(n,r) = n(n 1) (n r + 1) (0 r n) : P(3,2) = 3 x 2 = 6 Can be expressed as: P(n, r) = n! / (n r)! Note that P(n, 0) = 1. Question How many poker hands (five cards) can be dealt from a deck of 52 cards? How is this different than r-permutations?

Question 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 Unordered versus ordered selections Two ordered selections are the same if 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}? Permutations or combinations? Determine if the situation represents a permutation or a combination: 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. In how many ways can three student-council members be elected from five candidates? In how many ways can three student-council members be elected from five candidates to fill the positions of president, vice-president and treasurer A DJ will play three songs out of 10 requests. A) Permutations B) Combinations 19

Relationship between P(n,r) and C(n,r) Suppose we want to compute P(n,r). r-combinations 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 ) How many r-combinations? Note that C(n, 0) = 1 : How many poker hands (five cards) can be dealt from a deck of 52 cards? C(52,5) = 52! / (5!47!) P (n, r ) n! r! r! (n r )! 21 r-combinations How many r-combinations? Combinations or permutations? How many bit strings of length n contain exactly r ones? P(n,r) or C(n,r)? Note that C(n, 0) = 1 C(n,r) satisfies: We can see that easily without using the formula

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 coin is flipped 10 times, producing either heads or tails. How many possible outcomes A) B) C) D) How many permutations of {a,b,c,d,e,f,g} end with a? 5! 6! 7! 6 x 6! are there in total? contain exactly two heads? contain at least three heads? contain the same number of heads and tails? How many permutations of the letters ABCDEFGH contain the string ABC?

Some Advice about Counting How many 10 character (digits and lowercase/uppercase letters) passwords are possible if Apply the multiplication rule if a) characters cannot be repeated? Apply the addition rule if b) characters can be repeated? 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. 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 30 using Inclusion/Exclusion Rule Some more advice about Counting How many integers from 1 through 100 are multiples of 4 or multiples of 7? A: integers from 1 through 100 which are multiples of 4; B: integers from 1 through 100 which are multiples of 7. we want to find A B. A B = A + B - A B (incl./excl. rule) 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 A B is the set of integers from 1 through 100 which are multiples of 28. 31

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