In: Computer Science
Why the recursion in Pascal's Triangle is also the recursion for counting sub-sets.
If we closely look at the numbers of any row of Pascal's Triangle
For example row 6:
The fisrt value, second value........ till sixth value of row 6 are
In case of counting subsets
Number of subsets of size 1 in a set of 5 values:
Number of subsets of size 2 in a set of 5 values:
Number of subsets of size 3 in a set of 5 values:
Number of subsets of size 4 in a set of 5 values:
Number of subsets of size 5 in a set of 5 values:
Hence we can see that both the recursive program calculates nCr values. Therefore the recursive program in both the cases is same.