The Wayback Machine - https://web.archive.org/web/20240930191952/https://www.geeksforgeeks.org/generalized-pnc-set-1/
Open In App

Mathematics | Generalized PnC Set 1

Last Updated : 15 Dec, 2021
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Prerequisite – PnC and Binomial Coefficients 

So far every problem discussed in previous articles has had sets of distinct elements, but sometimes problems may involve repeated use of elements. This article covers such problems, where elements of the set are indistinguishable (or identical or not distinct). 

Permutations with repetition –
Counting permutations when repetition of elements can be easily done using the product rule. 
Example, number of strings of length r  is 26^r  , since for every character there are 26 possibilities. 

The number of r-permutations of a set of n objects 

with repetition is n^r.

Combinations with repetition –
Counting the number of combinations with repetition is a bit more complicated than counting permutations. Consider a set of n  types of objects and we need to find out in how many ways can r  elements be chosen. 
To solve the above problem we will first take a look at a similar problem that is arranging bars(|) and stars(*). Suppose there are 5 bars and 3 stars. One possible arrangement is –  

||*||**|


They can be arranged in \frac{8!}{5!3!} = C(8,3) = C(8,5)  ways. 
Our original problem is similar to the above problem. The bars represent divisions between the types of elements such that each type is separated by a bar and the number of stars is r  . 
If a star is before the nth bar, then that means an item of nth type is selected, except for the last type where the star can be after a bar. For example, the arrangement mentioned above, ||*||**|, represents a selection of 1 element of 3rd type and 2 elements of 5th type. 
In this way our original problem can be thought of as arranging r  stars (elements) and (n-1)  bars(divisions). The above result can be generalized as- 
 

There are C(r+n-1,r) = C(r+n-1,n-1) 

r-combinations from a set with n

elements when repetition is allowed.
  • Example 1 – In how many ways can 4 drinks can be chosen out of 6 possible types of drinks? There is no restriction on the number of drinks of a type that can be chosen and drinks of the same type are indistinguishable. 
     
  • Solution – The above scenario is a direct application of finding combinations with repetition. So the number of 4-combinations is – C(6-1+4,4) = C(9,4) = 126  . 
     
  • Example 2 – How many solutions does the equation x_1+x_2+x_3=11  have, where x_1, x_2,\:and\:x_2  are non-negative integers? 
     
  • Solution – x_1, x_2,\:and\:x_2  can have values ranging from 0 to 11. This situation is analogous to finding 11-combinations of 3 types of objects. 
    So number of solutions is –C(3-1+11,11) = C(13,11) = C(13,2) = 78

     
  • Example 3 – Consider the same question as Example 2 but with the additional constraint that x_1 \geq 1  . 
     
  • Solution – Since the minimum value of x_1  is 1, the effective equation becomes x_1+x_2+x_3=10  . So the number of solutions is- C(3-1+10,10) = C(12,10) = C(12,2) = 66
     
  • Example 4 – Consider the same question as Example 2 but with the additional constraint that x_1 < 2  . 
     
  • Solution – Since the constraint is not a lower limit but an upper limit, it cannot be solved in the same way as in Example 3. There is another way of solving such problems. 
    For each type of object we assign a polynomial of the form – x^{ll} + x^{ll+1} +...+ x^{ul}  , where ‘ll’ and ‘ul’ are the lower and upper limits for that type of object. 
    Then all such polynomials are multiplied and the coefficient of x^r  is the number of r  -combinations. 
    In our case, there is a constraint only on x_1  . Its polynomial therefore is- 
    x^0 + x^1
    Polynomial for x_2  and x_3  is- 
    x^0+x^1+x^2+x^3+x^4+x^5+x^6+x^7+x^8+x^9+x^{10}+x^{11}
    Since multiplying polynomials can be tedious, we use a trick which uses the binomial theorem. 
    The above polynomial can be extended to be an infinite series since the higher order terms won’t make any difference as we are only looking for the coefficient of x^{11}  . 
    So the polynomial for x_2  and x_3  is- 
    x^0+x^1+x^2+x^3+...+x^{11}+...
    The above polynomial is also the expansion for (1-x)^{-1}  . 
    On multiplying the polynomials we get- 
    (1+x)*\frac{1}{(1-x)^2}
    \frac{1}{(1-x)^2}  can be expanded through binomial theorem for negative exponents. We won’t need to expand the complete polynomial, as we just need the terms x^{11}  and x^{10}  , because they will be multiplied by 1 and x  to get terms of x^{11}  . 
    \frac{1}{(1+x)^n} = \sum_{k=0}^{\infty} \binom{n+k-1}{k} (-1)^k x^k  . 
    For x^{10}  [Tex]k=10  [/Tex], we get- 
    \binom{2 + 10 - 1}{10} (-1)^{10} (-x)^{10} = 11x^{10}
    For x^{11}  [Tex]k=11  [/Tex], we get- 
    \binom{2 + 11 - 1}{11} (-1)^{11} (-x)^{11} = 12x^{11}
    On multiplying the above obtained terms with x  and 1 we get terms of x^{11}  . On adding them up we get-23x^{11}  . 
    Therefore there are 23 solutions to the given equation. 
     
  • Example 5 – Consider the same question as in Example-2 but with an inequality i.e. x_1+x_2+x_3 \leq 11  . 
     
  • Solution – We could solve this problem in 2 ways. 
    One way is to add up all r  -combinations for values of r  starting from 0 upto 11 i.e. 
    x_1 + x_2 + x_3 = r  for 0\leq r \leq11  . We get the following values- 
    For r  = 0, ways = C(3-1+0,2) = C(2,2) = 1 
    For r  = 1, ways = C(3-1+1,2) = C(3,2) = 3 
    For r  = 2, ways = C(3-1+2,2) = C(4,2) = 6 
    For r  = 3, ways = C(3-1+3,2) = C(5,2) = 10 
    For r  = 4, ways = C(3-1+4,2) = C(6,2) = 15 
    For r  = 5, ways = C(3-1+5,2) = C(7,2) = 21 
    For r  = 6, ways = C(3-1+6,2) = C(8,2) = 28 
    For r  = 7, ways = C(3-1+7,2) = C(9,2) = 36 
    For r  = 8, ways = C(3-1+8,2) = C(10,2) = 45 
    For r  = 9, ways = C(3-1+9,2) = C(11,2) = 55 
    For r  = 10, ways = C(3-1+10,2) = C(12,2) = 66 
    For r  = 11, ways = C(3-1+11,2) = C(13,2) = 78 
    Total number of solutions = 364 
    The above problem is the same as finding the number of solutions for the equation- 
    x_1+x_2+x_3+x_4 = 11
    The extra variable can be thought of as the difference of 11 and (x_1+x_2+x_3)  . 
    When x_1+x_2+x_3  is 0, x_4  is 11. So x_4  takes values accordingly. 
    And the number of solutions of this equation is – C(4-1+11,4-1) = C(14,3) = 364. 
     

References –
Permutations and Combinations 
Discrete Mathematics and its Applications, by Kenneth H Rosen 
 



Previous Article
Next Article

Similar Reads

Mathematics | Generalized PnC Set 2
Prerequisite - Generalized PnC Set 1 Combinatorial problems can be rephrased in several different ways, the most common of which is in terms of distributing balls into boxes. So we must become familiar with the terminology to be able to solve problems. The balls and boxes can be either distinguishable or indistinguishable and the distribution can t
5 min read
Mathematics | PnC and Binomial Coefficients
Permutations and Combinations (PnC) are fundamental concepts in combinatorics and are essential for counting and arranging objects. Binomial coefficients are closely related and used in various mathematical formulas, including the Binomial Theorem. These concepts are widely used in engineering, computer science, probability, and statistics for solv
5 min read
Mathematics | Probability Distributions Set 2 (Exponential Distribution)
The previous article covered the basics of Probability Distributions and talked about the Uniform Probability Distribution. This article covers the Exponential Probability Distribution which is also a Continuous distribution just like Uniform Distribution. Introduction - Suppose we are posed with the question- How much time do we need to wait befor
5 min read
Discrete Mathematics | Types of Recurrence Relations - Set 2
Prerequisite - Solving Recurrences, Different types of recurrence relations and their solutions, Practice Set for Recurrence Relations The sequence which is defined by indicating a relation connecting its general term an with an-1, an-2, etc is called a recurrence relation for the sequence. Types of recurrence relations First order Recurrence relat
4 min read
Mathematics | Generating Functions - Set 2
Prerequisite - Generating Functions-Introduction and Prerequisites In Set 1 we came to know basics about Generating Functions. Now we will discuss more details on Generating Functions and its applications. Exponential Generating Functions - Let [Tex]h_0, h_1, h_2, ........., h_n, ...... [/Tex]e a sequence. Then its exponential generating function,
3 min read
Mathematics | Problems On Permutations | Set 2
Prerequisite - Permutation and Combination, Permutations | Set 1 Formula's Used : P(n, r) = n! / (n-r)! Example-1 : How many words can be formed from the letters of the word WONDER, such that these begin with W and end with R? Explanation : If we fix W in the beginning and R at the end, then the remaining 4 letters can be arranged in 4P4 ways. Thus
3 min read
Mathematics | Graph Theory Basics - Set 1
A graph is a data structure that is defined by two components : A node or a vertex.An edge E or ordered pair is a connection between two nodes u,v that is identified by unique pair(u,v). The pair (u,v) is ordered because (u,v) is not same as (v,u) in case of directed graph.The edge may have a weight or is set to one in case of unweighted graph.Cons
4 min read
Mathematics | Probability Distributions Set 5 (Poisson Distribution)
The previous article covered the Binomial Distribution. This article talks about another Discrete Probability Distribution, the Poisson Distribution. Introduction -Suppose an event can occur several times within a given unit of time. When the total number of occurrences of the event is unknown, we can think of it as a random variable. This random v
4 min read
Mathematics | Problems On Permutations | Set 1
Permutations are a fundamental concept in combinatorics, dealing with the arrangement of objects in a specific order. In mathematical terms, a permutation is an arrangement of a set of elements in a particular sequence or order. Understanding permutations is crucial not only in mathematics but also in various fields of engineering where precise arr
6 min read
Mathematics | Probability Distributions Set 1 (Uniform Distribution)
Prerequisite - Random Variable In probability theory and statistics, a probability distribution is a mathematical function that can be thought of as providing the probabilities of occurrence of different possible outcomes in an experiment. For instance, if the random variable X is used to denote the outcome of a coin toss ("the experiment"), then t
4 min read
Mathematics | Probability Distributions Set 3 (Normal Distribution)
The previous two articles introduced two Continuous Distributions: Uniform and Exponential. This article covers the Normal Probability Distribution, also a Continuous distribution, which is by far the most widely used model for continuous measurement. Introduction - Whenever a random experiment is replicated, the Random Variable that equals the ave
5 min read
Mathematics | Power Set and its Properties
For a given set S, Power set P(S) or 2^S represents the set containing all possible subsets of S as its elements. For example, S = {1, 2, 3} P(S) = {ɸ, {1}, {2}, {3} {1,2}, {1,3}, {2,3}, {1,2,3}} Number of Elements in Power SetFor a given set S with n elements, number of elements in P(S) is 2^n. As each element has two possibilities (present or abs
6 min read
Mathematics | Probability Distributions Set 4 (Binomial Distribution)
The previous articles talked about some of the Continuous Probability Distributions. This article covers one of the distributions which are not continuous but discrete, namely the Binomial Distribution. Introduction - To understand the Binomial distribution, we must first understand what a Bernoulli Trial is. A Bernoulli trial is a random experimen
5 min read
Mathematics | Graph Theory Basics - Set 2
Graph theory is a basic branch of discrete mathematics that mainly focuses on the relationship between objects. These objects are called vertices and these vertices are joined by edges. Graphs are common in computer science, network analysis, and many other everyday uses because they provide a good representation of connection, relationship, and pr
10 min read
Partial Orders and Lattices (Set-2) | Mathematics
Partial orders and lattices are important concepts in discrete mathematics and are widely used in computer science, especially in data structures, database theory, and the theory of computation. Partial orders and lattices play pivotal roles in a wide array of applications within engineering, computer science, and beyond. These structures enable th
10 min read
Mathematics | Unimodal functions and Bimodal functions
Unimodal Function : A function f(x) is said to be unimodal function if for some value m it is monotonically increasing for x≤m and monotonically decreasing for x≥m. For function f(x), maximum value is f(m) and there is no other local maximum. See figure (A) and (B): In figure (A), graph has only one maximum point and rest of the graph goes do
2 min read
Mathematics | Indefinite Integrals
Antiderivative - Definition :A function ∅(x) is called the antiderivative (or an integral) of a function f(x) of ∅(x)' = f(x). Example : x4/4 is an antiderivative of x3 because (x4/4)' = x3. In general, if ∅(x) is antiderivative of a function f(x) and C is a constant.Then, {∅(x)+C}' = ∅(x) = f(x). Indefinite Integrals
4 min read
Mathematics | Rings, Integral domains and Fields
Prerequisite - Mathematics | Algebraic Structure Ring - Let addition (+) and Multiplication (.) be two binary operations defined on a non empty set R. Then R is said to form a ring w.r.t addition (+) and multiplication (.) if the following conditions are satisfied: (R, +) is an abelian group ( i.e commutative group) (R, .) is a semigroup For any th
7 min read
Mathematics | Renewal processes in probability
A Renewal process is a general case of Poisson Process in which the inter-arrival time of the process or the time between failures does not necessarily follow the exponential distribution. A counting process N(t) that represents the total number of occurrences of an event in the time interval (0, t] is called a renewal process, if the time between
2 min read
Definite Integral | Mathematics
Definite integrals are the extension after indefinite integrals, definite integrals have limits [a, b]. It gives the area of a curve bounded between given limits. [Tex]\int_{a}^{b}F(x)dx [/Tex], It denotes the area of curve F(x) bounded between a and b, where a is the lower limit and b is the upper limit. Note: If f is a continuous function defined
1 min read
Application of Derivative - Maxima and Minima | Mathematics
The Concept of derivative can be used to find the maximum and minimum value of the given function. We know that information about and gradient or slope can be derived from the derivative of a function. We try to find a point which has zero gradients then locate maximum and minimum value near it. It is of use because it can be used to maximize profi
3 min read
Gamma Distribution Model in Mathematics
Introduction : Suppose an event can occur several times within a given unit of time. When the total number of occurrences of the event is unknown, we can think of it as a random variable. Now, if this random variable X has gamma distribution, then its probability density function is given as follows. [Tex]f(x) = \frac{1}{\beta^\alpha Γ(\alpha)} x^{
2 min read
Elementary Matrices | Discrete Mathematics
Prerequisite : Knowledge of Matrices & Identity Matrix Introduction :A matrix is a collection of numbers arranged in a row-by-row and column-by-column arrangement. The elements of a matrix must be enclosed in parenthesis or brackets.Example - The 3 * 3 matrix means a matrix with 3 rows & 3 columns with a total of 9 elements. (3*3 = 9) Ident
3 min read
Discrete Mathematics - GATE CSE Previous Year Questions
Solving GATE Previous Year's Questions (PYQs) not only clears the concepts but also helps to gain flexibility, speed, accuracy, and understanding of the level of questions generally asked in the GATE exam, and that eventually helps you to gain good marks in the examination. Previous Year Questions help a candidate practice and revise for GATE, whic
4 min read
Engineering Mathematics - GATE CSE Previous Year Questions
Solving GATE Previous Year's Questions (PYQs) not only clears the concepts but also helps to gain flexibility, speed, accuracy, and understanding of the level of questions generally asked in the GATE exam, and that eventually helps you to gain good marks in the examination. Previous Year Questions help a candidate practice and revise for GATE, whic
4 min read
Program for Gauss Seidel Method (Computational Mathematics)
The Gauss Seidel method is an iterative process to solve a square system of (multiple) linear equations. It is also prominently known as 'Liebmann' method. In any iterative method in numerical analysis, every solution attempt is started with an approximate solution of an equation and iteration is performed until the desired accuracy is obtained. In
3 min read
Mathematics | Graph theory practice questions
Problem 1 - There are 25 telephones in Geeksland. Is it possible to connect them with wires so that each telephone is connected with exactly 7 others. Solution - Let us suppose that such an arrangement is possible. This can be viewed as a graph in which telephones are represented using vertices and wires using the edges. Now we have 25 vertices in
4 min read
Mathematics | Hypergeometric Distribution model
Hypergeometric Distribution Model is used for estimating the number of faults initially resident in a program at the beginning of the test or debugging process based on the hypergeometric distribution. Let [Tex]$C_i-1$[/Tex] be the cumulative number of errors already detected so far by [Tex]$t_1, t_2, ...., t_i-1$[/Tex], and let [Tex]$N_i[/Tex] be
2 min read
JEE Mains Mathematics Preparation Experience
In the JEE Examination, the percentile calculation gives the highest priority to Mathematics, followed by Physics, and then Chemistry. Thus, it became crucial for me to focus more on Mathematics. Initially, while preparing for a few topics in 11th and 12th-grade Mathematics, I was able to understand and solve problems. However, I faced challenges w
3 min read
Engineering Mathematics - Well Formed Formulas (WFF)
Well-Formed Formula(WFF) is an expression consisting of variables(capital letters), parentheses, and connective symbols. An expression is basically a combination of operands & operators and here operands and operators are the connective symbols. Below are the possible Connective Symbols: ¬ (Negation)∧ (Conjunction)∨ (Disjunction)⇒ (Rightwards A
3 min read