Permutation
A permutation counts the ordered ways to choose k elements from n, P(n,k)=n!/(n-k)!; the full permutation count is n!.
Purpose
To count ordered selections, a foundation of combinatorics.
Mechanism
P(n,k) = n!/(n-k)! = n×(n-1)×...×(n-k+1). Full permutations P(n,n)=n!. Permutations with repetition P(n,k)=n^k. Circular permutations P(n,k)=(n-1)!. Generate all permutations with backtracking or Heap's algorithm.
Use cases
- Permutation generation and enumeration
- Password strength calculation
- Scheduling and ordering problems
- Probability computation
Examples
- Input
P(5,3)=5!/(5-3)!=60Output60Ordered arrangements of 3 out of 5
Common errors
- Confusing permutations with combinations (ordered vs unordered)
- Permutations are ordered (P), combinations unordered (C)
Related terms
Combination
A combination counts the ways to choose k elements from n without regard to order, C(n,k)=n!/(k!(n-k)!), i.e., the binomial coefficient. GLOSSARY
Factorial
The factorial n! = n×(n-1)×...×1 is the basis of permutations and combinations; it grows extremely fast, with 20! already exceeding the 64-bit integer range. GLOSSARY