Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 115 Chapter 3 Counting. CSCI 115 §3.1 Permutations.

Similar presentations


Presentation on theme: "CSCI 115 Chapter 3 Counting. CSCI 115 §3.1 Permutations."— Presentation transcript:

1 CSCI 115 Chapter 3 Counting

2 CSCI 115 §3.1 Permutations

3 §3.1 – Permutations Theorem 3.1.1 – Multiplication Principle of Counting –Suppose 2 tasks t 1 and t 2 are to be performed in sequence. If t 1 can be performed in n 1 ways, and t 2 can be performed in n 2 ways, then the sequence of tasks t 1 t 2 can be performed in n 1 n 2 ways.

4 §3.1 – Permutations Theorem 3.1.2 –Suppose tasks t 1, t 2, …, t k are to be performed in sequence. If t 1 can be performed in n 1 ways, t 2 can be performed in n 2 ways and so on, then the sequence of tasks t 1 t 2 …t k can be performed in n 1 n 2 … n k ways.

5 §3.1 – Permutations Consider the following problem: –How many different sequences, each of length r, can be formed from the elements of a set A if: Elements can be repeated Elements in the sequence must be distinct –Number of permutations of n objects taken r at a time

6 §3.1 – Permutations Theorem 3.1.3 –Let A be a set with n elements, r  Z +, with 1  r  n. The number of sequences of length r that can be formed from elements of A, allowing repetitions, is n r.

7 §3.1 – Permutations Theorem 3.1.4 –Let A be a set with n elements, r  Z +, with 1  r  n. The number of permutations of n objects taken r at a time is: n. (n – 1). (n – 2)... (n – (r – 1)) and is denoted n P r. –Equivalently: n!. (n – r)! Factorials

8 CSCI 115 §3.2 Combinations

9 §3.2 – Combinations Consider the following problem: –Let A be any set with n elements, 1  r  n, r  Z +. How many different subsets of r elements are there? Number of combinations of n objects taken r at a time

10 §3.2 – Combinations Theorem 3.2.1 –Let A be a set with |A| = n. Let r  Z + with 1  r  n. The number of combinations of n objects taken r at a time is n!. r!(n – r)! and is denoted n C r.

11 CSCI 115 §3.4 Elements of Probability

12 §3.4 – Elements of Probability Deterministic Experiment –Outcome should not change Finding acceleration due to gravity Probabilistic Experiment –Outcome can change Rolling a die and recording the outcome We will be discussing probabilistic experiments

13 §3.4 – Elements of Probability Sample space Event –Subset of sample space –Certain event –Impossible Event Mutually exclusive events

14 §3.4 – Elements of Probability Notation - Assigning probabilities to events –P(E) Frequency –If you have n experiments and E occurs n E times, then: f E = n E /n is the Frequency of occurrence of E in n trials f E  P(E) as n 

15 §3.4 – Elements of Probability Probability Spaces Axioms for a probability space A: –P1: 0  P(E)  1  E  A –P2: P(A) = 1 and P(  ) = 0 –P3: If E 1, E 2, …, E k are all mutually exclusive, then: P(E 1  E 2  …  E k ) = P(E 1 ) + P(E 2 ) + … + P(E k )

16 §3.4 – Elements of Probability Probability Spaces –Elementary Events (x i ) –Elementary Probability (P i = P({x i })) All the x i are mutually exclusive, and we have: –EP1: 0  P i  1 –EP2: P 1 + P 2 + … + P n = 1

17 §3.4 – Elements of Probability Equally likely outcomes –|A| = n, and all elementary events are equally likely, then: If E = {x 1, x 2, …, x k } then P(E) = k/n or P(E) = |E|/|A|

18 §3.4 – Elements of Probability Expected value –Sum of the value of each outcome times its probability –A way to calculate the ‘average’ value

19 CSCI 115 §3.5 Recurrence Relations

20 §3.5 – Recurrence Relations Recall sequences –Recursive –Explicit Recurrence relation –When an equivalent explicit formula is needed, the recursive formula is called a recurrence relation

21 §3.5 – Recurrence Relations Backtracking –‘Track’ the equation ‘back’ to an explicit formula –Does not always work

22 §3.5 – Recurrence Relations Linear Homogeneity –A recurrence relation is linearly homogenous of degree k if: a n = r 1 a n-1 + r 2 a n-2 + … + r k a n-k r i is constant  i –A recurrence relation that is linearly homogenous of degree k has the following characteristic equation: x k = r 1 x k-1 + r 2 x k-2 + … + r k The characteristic equation plays a role in determining the explicit formula

23 §3.5 – Recurrence Relations Theorem 3.5.1 –If the characteristic equation x 2 – r 1 x – r 2 = 0 of the recurrence relation a n = r 1 a n-1 + r 2 a n-2 has 2 distinct roots s 1 and s 2, then a n = us 1 n + vs 2 n (where u and v depend on initial conditions) is the explicit formula for the sequence. –If the characteristic equation x 2 – r 1 x – r 2 = 0 of the recurrence relation a n = r 1 a n-1 + r 2 a n-2 has a single root s, then a n = us n + vns n (where u and v depend on initial conditions) is the explicit formula for the sequence.

24 §3.5 – Recurrence Relations Algorithm for solving a linearly homogenous recurrence relation 1.Determine if the recurrence relation is linearly homogenous, and if so, determine its degree 2.Find and solve the corresponding characteristic equation 3.Use the appropriate part of the theorem to determine which template to use 4.Find and solve the corresponding system of equations 5.Write out the corresponding explicit sequence 6.Check at least one term to ensure the recursive and explicit sequences generate the same value


Download ppt "CSCI 115 Chapter 3 Counting. CSCI 115 §3.1 Permutations."

Similar presentations


Ads by Google