Permutations and Combinations Review Plus a little Dry Run, Sorting and Code.

Slides:



Advertisements
Similar presentations
Permutations and Combinations
Advertisements

Counting Principles The Fundamental Counting Principle: If one event can occur m ways and another can occur n ways, then the number of ways the events.
Statistics Review. Box-and-Whisker Plots The Parts of a Box and Whisker Plot Name the parts of a Box-and-Whisker Plot MedianUpper Quartile Lower.
How many possible outcomes can you make with the accessories?
___ ___ ___ ___ ___ ___ ___ ___ ___
Chapter 2 Section 2.4 Permutations and Combinations.
Permutations and Combinations AII Objectives:  apply fundamental counting principle  compute permutations  compute combinations  distinguish.
Expected value a weighted average of all possible values where the weights are the probabilities of each outcome :
Permutations and Combinations. Random Things to Know.
P ERMUTATIONS AND C OMBINATIONS Homework: Permutation and Combinations WS.
Permutations and Combinations
Permutations and Combinations. Objectives:  apply fundamental counting principle  compute permutations  compute combinations  distinguish permutations.
Warm Up Evaluate  4  3  2   6  5  4  3  2 
Permutations, Combinations, and Counting Theory AII.12 The student will compute and distinguish between permutations and combinations and use technology.
March 10,  Counting  Fundamental Counting principle  Factorials  Permutations and combinations  Probability  Complementary events  Compound.
Permutations and Combinations
PERMUTATIONS AND COMBINATIONS BOTH PERMUTATIONS AND COMBINATIONS USE A COUNTING METHOD CALLED FACTORIAL.
Permutations and Combinations. Objectives:  apply fundamental counting principle  compute permutations  compute combinations  distinguish permutations.
Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)
Permutations, Combinations, and Counting Theory
Lesson 0.4 (Counting Techniques)
Counting Techniques Tree Diagram Multiplication Rule Permutations Combinations.
37. Permutations and Combinations. Fundamental Counting Principle Fundamental Counting Principle states that if an event has m possible outcomes and another.
Java Methods 11/10/2015. Learning Objectives  Be able to read a program that uses methods.  Be able to write a write a program that uses methods.
Warm up How many possible pizzas could you make with 3 types of meats, 2 types of cheeses, and 2 types of sauces? 5 * 4 * 3 * 2 * 1 =
 Counting  Fundamental Counting principle  Factorials  Permutations and combinations  Probability  Complementary events  Compound events  Independent.
Discrete Math Section 15.3 Solve problems using permutations and combinations Read page Combinations and permutations.
Permutations and Combinations
Permutations and Combinations AII Objectives:  apply fundamental counting principle  compute permutations  compute combinations  distinguish.
Array Review Selection Sort Get out your notes.. Learning Objectives Be able to dry run programs that use arrays Be able to dry run programs that use.
Quiz: Draw the unit circle: Include: (1)All “nice” angles in degrees (2) All “nice” angles in radians (3) The (x, y) pairs for each point on the unit circle.
Permutations and Combinations. Fundamental Counting Principle Fundamental Counting Principle states that if an event has m possible outcomes and another.
13 Lesson 1 Let Me Count the Ways Fundamental Counting Principle, Permutations & Combinations CP Probability and Statistics FA 2014 S-ID.1S-CP.3S-CP.5.
Permutations and Combinations
Happy Pi Day! Find x. 15 If you still have x
BASIC PROBABILITY Probability – the chance of something (an event) happening # of successful outcomes # of possible outcomes All probability answers must.
Counting Techniuqes.
Chapter 0.4 Counting Techniques.
Discrete Math Section 15.3 Solve problems using permutations and combinations Read page Combinations and permutations.
Array Review Selection Sort
Permutations and Combinations
Permutations and Combinations
Warm Up Permutations and Combinations Evaluate  4  3  2  1
Sorts on the AP Exam Insertion Sort.
Permutations and Combinations
Probability Warm Up page 12- write the question you have 10 mins to complete it. See coaching on page 85.
Permutations and Combinations
Lesson 11-1 Permutations and Combinations
Permutations and Combinations
Permutations and Combinations
10.4 Permutations and Combinations
Counting techniques Basic Counting Principles, Pigeonhole Principle, Permutations and Combinations.
Permutations and Combinations
First lecture fsalamri Faten alamri.
How many possible outcomes can you make with the accessories?
Dry Run Practice Use Methods with an Insertion Sort
Counting Principle.
Bellwork Practice Packet 10.3 B side #3.
Probability Warm Up page 12- write the question you have 10 mins to complete it. See coaching on page 85.
Day 2 - Combinations.
Permutations and Combinations
Standard DA-5.2 Objective: Apply permutations and combinations to find the number of possibilities of an outcome.
Permutations and Combinations
Array Review Selection Sort
Fundamental Counting Theorm
Lecture 7: Permutations and Combinations
Permutations and Combinations
Permutations and Combinations
Presentation transcript:

Permutations and Combinations Review Plus a little Dry Run, Sorting and Code.

Objectives:  Review Permutations and Combinations  apply fundamental counting principle  compute permutations  compute combinations  distinguish permutations vs combinations  Practice reading methods that use parameters  Review Insertion Sort  Write a program that incorporates the insertion sort.

Fundamental Counting Principle Fundamental Counting Principle can be used determine the number of possible outcomes when there are two or more characteristics. Fundamental Counting Principle states that if an event has m possible outcomes and another independent event has n possible outcomes, then there are m * n possible outcomes for the two events together.

Fundamental Counting Principle Lets start with a simple example. A student is to roll a die and flip a coin. How many possible outcomes will there be? 1H 2H 3H 4H 5H 6H 1T 2T 3T 4T 5T 6T 12 outcomes 6*2 = 12 outcomes

Fundamental Counting Principle For a college interview, Robert has to choose what to wear from the following: 4 slacks, 3 shirts, 2 shoes and 5 ties. How many possible outfits does he have to choose from? 4*3*2*5 = 120 outfits

Permutations A Permutation is an arrangement of items in a particular order. Notice, ORDER MATTERS! To find the number of Permutations of n items, we can use the Fundamental Counting Principle or factorial notation.

Permutations The number of ways to arrange the letters ABC: ____ ____ ____ Number of choices for first blank ? 3 ____ ____ 3 2 ___ Number of choices for second blank? Number of choices for third blank? *2*1 = 6 3! = 3*2*1 = 6 ABC ACB BAC BCA CAB CBA

Permutations To find the number of Permutations of n items chosen r at a time, you can use the formula

Permutations A combination lock will open when the right choice of three numbers (from 1 to 30, inclusive) is selected. How many different lock combinations are possible assuming no number is repeated? Practice: Answer Now

Permutations A combination lock will open when the right choice of three numbers (from 1 to 30, inclusive) is selected. How many different lock combinations are possible assuming no number is repeated? Practice:

Permutations From a club of 24 members, a President, Vice President, Secretary, Treasurer and Historian are to be elected. In how many ways can the offices be filled? Practice: Answer Now

Permutations From a club of 24 members, a President, Vice President, Secretary, Treasurer and Historian are to be elected. In how many ways can the offices be filled? Practice:

Combinations A Combination is an arrangement of items in which order does not matter. ORDER DOES NOT MATTER! Since the order does not matter in combinations, there are fewer combinations than permutations. The combinations are a "subset" of the permutations.

Combinations To find the number of Combinations of n items chosen r at a time, you can use the formula

Combinations To find the number of Combinations of n items chosen r at a time, you can use the formula

Combinations To play a particular card game, each player is dealt five cards from a standard deck of 52 cards. How many different hands are possible? Practice: Answer Now

Combinations To play a particular card game, each player is dealt five cards from a standard deck of 52 cards. How many different hands are possible? Practice:

Combinations A student must answer 3 out of 5 essay questions on a test. In how many different ways can the student select the questions? Practice: Answer Now

Combinations A student must answer 3 out of 5 essay questions on a test. In how many different ways can the student select the questions? Practice:

Combinations A basketball team consists of two centers, five forwards, and four guards. In how many ways can the coach select a starting line up of one center, two forwards, and two guards? Practice: Answer Now

Combinations A basketball team consists of two centers, five forwards, and four guards. In how many ways can the coach select a starting line up of one center, two forwards, and two guards? Practice: Center: Forwards:Guards: Thus, the number of ways to select the starting line up is 2*10*6 = 120.

Summary Permutations: Order matters The number of Permutations of n items chosen r at a time, you can use the formula Combinations: Order does not matter. To find the number of Combinations of n items chosen r at a time, you can use the formula

Stats Pack: Write a program with methods to calculate the following. Factorial –Sent a positive integer, returns its factorial. (Note: 0! = 1) Combinations Write a method that will find the number of combinations of n items taken r at a time. Combinations of n items take r at a time= n!/((r!)(n-r)!) –Enter the values for n and r in the main body –Calculate and return the number of combinations in the method –Show the number of combinations in the main body. Permutations Write a method that will find the number of permutations of n items taken r at a time. Permutations of n items taken r at a time= n!/(n-r)! –Enter the values for n and r in the main body –Calculate and return the number of combinations in the method –Show the number of combinations in the main body.

Learning Objectives Be able to read a methods that are passed parameters. Be able to write a second program that uses methods.

Multiple Choice CTA9 (none). Consider the following static method public static double getSomething(int val) { val = 2 * val; val = val + 2 * val; return val; } Which of the following could be used to replace the body of getSomething so that the modified version will return the same result as the original version for all values of the parameter val. A.return 2 * val; B.return 3 * val; C.return 4 * val; D.return 5 * val; E.return 6 * val;

Multiple Choice CTA10 (A1.15). Consider the following static method public static double getSomething(int val) { val = 2 + val; val = val + 3*val; return val; } Which of the following could be used to replace the body of getSomething so that the modified version will return the same result as the original version for all values of the parameter val. A.return 4*val + 2; B.return 4*val + 6; C.return 4*val + 8; D.return 7*val + 6; E.return 7*val + 8;

public static void sort(String [] list) { for(int start = 0; start < list.length-1; start++) { int index = start; for(int k = start + 1; k < list.length; k++) { if(list[k].compareTo(list[index]) > 0) index = k; } String temp = list[start]; list[start] = list[index]; list[index] = temp; } Assume the String array words is initialized as shown below. word What will the array word look like after the third pass through the outer loop in the call sort(word)? Note how an array is passed to a method. BillJoeSueAnnMelZeb

Multiple Choice A20 (A3.32). Consider the incomplete method ChoiceOfThree. public int choiceOfThree() { // missing code } Method choiceOfThree is intended to return one of the values 1, 2, 3, each with probability 1/3. Consider the following replacements for //missing code. I.return (int)(Math.random() * 3); II.return (int)(Math.random() * 3) + 1; III.if(Math.random() < 1.0/3.0) return 1; else if (Math.random() < 2.0/3.0) return 2; else return 3; Which if these replacements for //missing code will make choiceOfThree work as intended? A. I onlyB. II onlyC. III onlyD. I and IIIE. II and III

Insertion sort How it works Example LowHigh Stability Speed Your turn HighLow Dummy, slide, back Stable O(n 2 )

Insertion Sort // a is the name of the array // nElems stores the number of elements being sorted // This example is for sorting an array of ints int in, out; for(out=1; out<nElems; out++) // out is dividing line { int dummy = a[out]; // dummy Need to modify for sorting different types in = out; // start shifts at out while(in>0 && a[in-1] >= dummy) // until one is smaller, What if sorting Strings? { a[in] = a[in-1]; // Slide: shift item right, in--; // go left one position } a[in] = dummy; // Back: insert marked item } // end for

Second Method Program Main Body –Get 9 scores –Call methods –Show results Scores in order Low to High Mean, median Push: Mode, standard deviation Push: Handle getting an unknown number (but less than 100) of values. Methods –Insertion Sort –Mean –Median –Push: Mode, standard deviation