Permutations and Combinations

COS1501 - Theoretical Computer Science I · Counting Principles

Permutations and Combinations

Permutations and combinations are fundamental concepts in counting principles. They help in determining the number of ways to arrange or select items from a set. Understanding these concepts is crucial in various fields, including computer science, statistics, and probability.

Permutations

A permutation is an arrangement of items in a specific order. The order of arrangement matters in permutations. For example, the arrangement of letters in the word 'CAT' (i.e., CAT, ACT, TCA) is different from the arrangement of letters in 'COT' (i.e., COT, OTC, TCO).

Formula for Permutations

The formula for calculating permutations of n items taken r at a time is:

P(n, r) = n! / (n - r)!

Where:

  • P(n, r) = number of permutations
  • n = total number of items
  • r = number of items to arrange
  • n! = factorial of n (the product of all positive integers up to n)
  • (n - r)! = factorial of (n - r)

Example of Permutations

Suppose you have 5 books and you want to arrange 3 of them on a shelf. Here, n = 5 and r = 3.

Using the formula:

P(5, 3) = 5! / (5 - 3)! = 5! / 2!

Calculating the factorials:

5! = 5 × 4 × 3 × 2 × 1 = 120

2! = 2 × 1 = 2

Now substitute these values back into the equation:

P(5, 3) = 120 / 2 = 60

Thus, there are 60 different ways to arrange 3 books out of 5.

Remember: The order matters in permutations. Changing the order of the items results in a different arrangement.

Combinations

A combination is a selection of items without regard to the order. In combinations, the arrangement of items does not matter. For example, selecting the letters A, B, and C is the same as selecting C, B, and A.

Formula for Combinations

The formula for calculating combinations of n items taken r at a time is:

C(n, r) = n! / (r! × (n - r)!)

Where:

  • C(n, r) = number of combinations
  • n = total number of items
  • r = number of items to choose
  • r! = factorial of r
  • (n - r)! = factorial of (n - r)

Example of Combinations

Suppose you have 5 books and you want to select 3 of them to read. Here, n = 5 and r = 3.

Using the formula:

C(5, 3) = 5! / (3! × (5 - 3)!) = 5! / (3! × 2!)

Calculating the factorials:

5! = 120, 3! = 6, 2! = 2

Now substitute these values back into the equation:

C(5, 3) = 120 / (6 × 2) = 120 / 12 = 10

Thus, there are 10 different ways to choose 3 books out of 5.

Remember: The order does not matter in combinations. Selecting A, B, and C is the same as selecting C, B, and A.

Relationship Between Permutations and Combinations

Permutations and combinations are related. Specifically, the number of permutations can be calculated from combinations. The relationship is given by:

P(n, r) = C(n, r) × r!

This means that to find the number of permutations of r items from n items, you can first find the number of combinations and then multiply by the number of ways to arrange those r items.

Example of Relationship

Using the previous example of selecting 3 books from 5:

We found:

C(5, 3) = 10

Now, calculate the permutations:

P(5, 3) = C(5, 3) × 3! = 10 × 6 = 60

This confirms our earlier calculation of 60 permutations.

Watch out: Do not confuse permutations with combinations. Remember that permutations consider the order, while combinations do not.

Applications of Permutations and Combinations

Permutations and combinations have many practical applications. They are used in:

  • Statistics for sampling methods
  • Computer science for algorithm analysis
  • Game theory for strategy development
  • Cryptography for code generation

Common Mistakes

Students often make mistakes when applying the formulas for permutations and combinations. Here are some common errors:

  • Confusing permutations with combinations
  • Incorrectly calculating factorials
  • Forgetting to consider the total number of items

Tip: Always double-check your calculations when working with factorials and ensure you understand whether you need to use permutations or combinations.

Summary

  • Permutations are arrangements where order matters.
  • Combinations are selections where order does not matter.
  • The formula for permutations is P(n, r) = n! / (n - r)!
  • The formula for combinations is C(n, r) = n! / (r! × (n - r)!)
  • Permutations can be derived from combinations using P(n, r) = C(n, r) × r!

Check your understanding

  1. What is the difference between permutations and combinations?
  2. Calculate the number of ways to arrange 4 items from a set of 6.
  3. How many ways can you choose 2 fruits from a basket of 5 different fruits?
  4. Explain why the formula for permutations includes (n - r)! in the denominator.