Counting the objects that satisfy some criteria is a very common task in both Programming and in real-life situations. The myriad ways of counting the number of elements in a set is one of the main tasks in combinatorics, and I’ll try to describe some basic aspects of it in this blog.
Combinatorics is all about number of ways of choosing some objects out of a collection and/or number of ways of their arrangement. For example suppose there are five members in a club, let's say there names are A, B, C, D, and E, and one of them is to be chosen as the coordinator. Clearly any one out of them can be chosen so there are 5 ways. Now suppose two members are to be chosen for the position of coordinator and co-coordinator. Now, we can choose A as coordinator and one out of the rest 4 as co-coordinator. Similarly we can choose B as coordinator and one of out the remaining 4 as co-coordinator, and similarly with C, D and E. So there will be total 20 possible ways.
Combinatorial primitives
Let’s begin with a quick overview of the basic rules and objects that we will reference later.
The rule of sum

The rule of product

Let's generalize it. Permutations of choosing R disticnt objects out of a collection of N objects can be calculated using the following formula:

Combinations of choosing R distinct objects out of a collection of N objects can be calculated using the following formula:

Basic Combinatorics Rules:
- The Rule of Product:
The product rule states that if there are X number of ways to choose one element from A and Y number of ways to choose one element from B, then there will be X*Y number of ways to choose two elements, one from A and one from B. - The Rule of Sum:
The sum rule states that if there are X number of ways to choose one element from A and Y number of ways to choose one element from B, then there will be X+Y number of ways to choose one element that can belong to either A or to B.
These rules can be used for a finite collections of sets.
Permutations with repetition:

Permutations without repetition:
Combinations with repetition:
Combinations without repetition:
- Hall M. "Combinatorial theory"
- Cameron P.J. "Combinatorics: Topics, Techniques, Algorithms"
- en.wikipedia.org :-)
Comments
Post a Comment