Home Previous year paper Algorithms Notes About us
Combinatorics Basics

Combinatorics is the branch of Mathematics dealing with the study of finite or countable discrete structures. It includes the enumeration or counting of objects having certain properties. Counting helps us solve several types of problems such as counting the number of available IPv4 or IPv6 addresses.

Counting Principles –

There are two basic counting principles, sum rule and product rule.
Sum Rule – If a task can be done in one of n1 ways or one of n2 ways, where none of the set of n1 ways is the same as any of the set of n2 ways, then there are n1 + n2 ways to do the task.
Product Rule – If a task can be broken down into a sequence of k subtasks, where each subtask can be performed in n1, n2,.. nk respectively, then the total number of ways the task can be performed is n1* n2 * ... * nk .

Principle of Inclusion-Exclusion :

The sum-rule mentioned above states that if there are multiple sets of ways of doing a task, there shouldn’t be any way that is common between two sets of ways because if there is, it would be counted twice and the enumeration would be wrong.
The principle of inclusion-exclusion says that in order to count only unique ways of doing a task, we must add the number of ways to do it in one way and the number of ways to do it in another and then subtract the number of ways to do the task that are common to both sets of ways.
The principle of inclusion-exclusion is also known as the subtraction principle. For two sets of ways A1 and A2 , the enumeration would like-