Count of permutations of size 2N with at least N increasing elements


Permutations are arrangements of objects in a specific order. In mathematics, a permutation of a set is an arrangement of its elements, without repetition and order being important. Permutations play a significant role in various fields of mathematics, including combinatorics, group theory, and algebra. In this article, we will discuss the count of permutations of size 2N with at least N increasing elements and explain it with an example.

C++ CODE

// C++ implementation of the approach
  
#include <bits/stdc++.h>
using namespace std;
  
// Function that returns the count of
// all permutations of size 2N having
// atleast N increasing elements.
int countPermutations(int N)
{
    int ans = 1;
    // calculate (2N)!
    for (int i = 1; i <= 2 * N; i++)
        ans = ans * i;
  
    return ans / 2;
}
  
// Driver code
int main()
{
    int N = 2;
  
    // Function Call
    cout << countPermutations(N);
    return 0;
}

Output : 

12

Time Complexity: O(N), as we only need to calculate (2N)! which can be calculated in O(N) time

Auxiliary Space: O(1)

Example : 

Let us consider the set \( {1, 2, 3, ..., 2N} \), and we want to find the count of permutations of size 2N with at least N increasing elements. In other words, we want to find the number of ways to arrange the elements of this set in such a way that at least N elements are in increasing order.

One way to approach this problem is to use the principle of inclusion-exclusion. Let A be the set of permutations of size 2N with exactly N increasing elements, and let B be the set of permutations of size 2N with exactly N+1 increasing elements. Then, the count of permutations of size 2N with at least N increasing elements is given by:

\( |A ∪ B| = |A| + |B| - |A ∩ B| \)

Here, |A| is the number of permutations of size 2N with exactly N increasing elements, |B| is the number of permutations of size 2N with exactly N+1 increasing elements, and |A ∩ B| is the number of permutations of size 2N with exactly N+2 increasing elements.

Let us first find the count of permutations of size 2N with exactly N increasing elements. For this, we can use the following approach:

Choose N elements from the set {1, 2, 3, ..., 2N} that will be in increasing order. This can be done in (2N choose N) ways.
Arrange these N elements in increasing order. This can be done in only 1 way.
Arrange the remaining N elements in any order. This can be done in (N choose N) ways.
Therefore, the count of permutations of size 2N with exactly N increasing elements is given by:

\( |A| = (2N choose N) * 1 * (N choose N) = (2N choose N) \)

Next, let us find the count of permutations of size 2N with exactly N+1 increasing elements. For this, we can use a similar approach:

Choose N+1 elements from the set {1, 2, 3, ..., 2N} that will be in increasing order. This can be done in (2N choose N+1) ways.
Arrange these N+1 elements in increasing order. This can be done in only 1 way.
Arrange the remaining N-1 elements in any order. This can be done in (N choose N-1) ways.
Therefore, the count of permutations of size 2N with exactly N+1 increasing elements is given by:

 

Finally, let us find the count of permutations of size 2N with exactly N+2 increasing elements. For this, we can use a similar approach:

Choose N+2 elements from the set {1, 2, 3, ..., 2N} that will be in increasing order. This can be done in (2N choose N+2) ways.

Arrange these N+2 elements in increasing order. This can be done in only 1 way.

Arrange the remaining N-2 elements in any order. This can be done in (N choose N-2) ways.

Therefore, the count of permutations of size 2N with exactly N+2 increasing elements is given by:

\( |A ∩ B| = (2N choose N+2) * 1 * (N choose N-2) = (2N choose N+2) * (N-1) \)

Substituting the values of |A|, |B|, and |A ∩ B| in the formula for |A ∪ B|, we get:

\( |A ∪ B| = (2N choose N) + (2N choose N+1) * N - (2N choose N+2) * (N-1) \)

Simplifying this expression, we get:

\( |A ∪ B| = (2N choose N) * (N+1) \)

Therefore, the count of permutations of size 2N with at least N increasing elements is (2N choose N) * (N+1). This formula can also be interpreted as follows: first, choose N elements from the set \( {1, 2, 3, ..., 2N} \) that will be in increasing order. This can be done in (2N choose N) ways. Then, choose any one of the remaining N+1 positions to insert the remaining N elements. This can be done in (N+1) ways. Therefore, the total count is (2N choose N) * (N+1).

Let us illustrate this with an example. Suppose N=2, so we want to find the count of permutations of size 4 with at least 2 increasing elements. The set {1, 2, 3, 4} has 6 possible permutations, which are:

1 2 3 4

1 2 4 3

1 3 2 4

1 3 4 2

1 4 2 3

1 4 3 2

Out of these, only the first 4 have at least 2 increasing elements. Therefore, the count we are looking for is 4. We can verify that the formula (2N choose N) * (N+1) gives the same result:

\( (2N choose N) * (N+1) = (4 choose 2) * 3 = 4 \)

In this example, we can also see that the permutations with at least 2 increasing elements have either 2 or 3 increasing elements. The permutations with 2 increasing elements are 1 2 4 3 and 1 3 4 2, and the permutations with 3 increasing elements are 1 2 3 4 and 1 3 2 4. This observation can be generalized as follows:

If a permutation of size 2N has at least N increasing elements, then it has either N, N+1, or N+2 increasing elements.

To see why this is true, suppose a permutation has k increasing elements, where k is greater than N+2. Then, there must exist two adjacent increasing elements, say i and i+1, where i is less than N+1. But then, there must exist two adjacent decreasing elements to the right of i+1, say j and j+1. Since i is less than N+1, j is greater than N, and j+1 is greater than N+1, there are no more increasing elements left to fill the remaining positions. Therefore, the permutation cannot have more than N increasing elements. On the other hand, if a permutation has N increasing elements, we can always add one more increasing element by choosing any two adjacent elements that are not in increasing order and swapping them. This will create a new increasing element without changing the count of increasing elements. Therefore, any permutation with at least N increasing elements can be transformed into a permutation with exactly N+1 increasing elements by applying a sequence of such swaps. Similarly, a permutation with N+1 increasing elements can be transformed into a permutation with N+2 increasing elements. Therefore, any permutation with at least N increasing elements has either N, N+1, or N+2 increasing elements.

In summary, we have derived a formula for the count of permutations of size 2N with at least N increasing elements:

\( (2N choose N) * (N+1) \)

This formula can be interpreted as choosing N elements from the set {1, 2, ..., 2N} that will be in increasing order, and then inserting the remaining N elements in any of the N+1 possible positions. We have also shown that any permutation with at least N increasing elements has either N, N+1, or N+2 increasing elements.

This formula has several applications in combinatorics and probability theory. For example, it can be used to compute the probability that a random permutation of size 2N has at least N increasing elements. This probability can be computed as the ratio of the count of permutations with at least N increasing elements to the total count of permutations, which is (2N)!:

\( P(N, 2N) = [(2N choose N) * (N+1)] / (2N)! \)

For large values of N, this probability can be approximated using Stirling's formula for the factorial:

\( N!(2πN)^(1/2) (N/e)^N \)

as:

\( P(N, 2N) ≈ [(2πN)^(1/2) / 2N] * [(2N/e)^N / (N/e)^N * (N+1)] = [(2πN)^(1/2) / 2N] * (N+1) / (e^N) \)

This approximation shows that the probability of a random permutation having at least N increasing elements decreases exponentially with N. This makes intuitive sense, as the number of possible permutations grows exponentially with N, while the number of permutations with at least N increasing elements grows much more slowly.

In addition, the formula (2N choose N) * (N+1) can be used to solve various combinatorial problems involving permutations with increasing subsequences. For example, the Erdős-Szekeres theorem states that any sequence of N^2+1 distinct numbers must contain either an increasing subsequence of length N+1 or a decreasing subsequence of length N+1. This theorem can be proved using the pigeonhole principle, and the proof relies on the fact that the count of permutations with at least N+1 increasing elements is greater than the count of permutations with at most N increasing elements. Therefore, if we have N^2+1 distinct numbers and want to show that there exists an increasing subsequence of length N+1, we can map each number to its position in a permutation of size 2N with at least N+1 increasing elements, and apply the Erdős-Szekeres theorem to the permutation.

In conclusion, we have derived a formula for the count of permutations of size 2N with at least N increasing elements, and shown how it can be applied to various combinatorial problems. The formula (2N choose N) * (N+1) provides a simple and elegant solution to these problems, and highlights the importance of counting techniques in combinatorics and probability theory. By understanding the properties of permutations with increasing subsequences, we can solve a wide range of problems in these fields, from analyzing the performance of sorting algorithms to computing the probabilities of winning certain games.

Furthermore, the formula we derived for the count of permutations with at least N increasing elements has many interesting properties that are worth exploring. For example, we can use generating functions to derive a closed-form expression for the sum of the counts of permutations with k increasing elements for all k between N and 2N. This involves constructing a generating function for the count of permutations with at least N increasing elements, and then using the derivative of this generating function to compute the desired sum. This approach can be generalized to other types of permutations, such as those with restricted patterns or inversions.

Another interesting property of the count of permutations with at least N increasing elements is that it satisfies a recurrence relation that can be used to compute it efficiently. Specifically, let P(N, k) denote the count of permutations of size 2N with exactly k increasing elements. Then we have:

\( P(N, k) = (N-k+2) * P(N-1, k-1) + (k-1) * P(N-1, k) \)

This recurrence relation can be proved using a combinatorial argument based on the last element of the permutation, and it allows us to compute the count of permutations with at least N increasing elements in O(N^2) time using dynamic programming. This is much faster than the naive approach of enumerating all permutations and counting the ones with at least N increasing elements, which takes O((2N)!N) time.

In addition to these properties, the count of permutations with at least N increasing elements has connections to other areas of mathematics, such as algebraic combinatorics, algebraic geometry, and representation theory. For example, the generating function for the count of permutations with at least N increasing elements is a special case of the Schur polynomial, which is a fundamental object in the study of symmetric functions and representation theory. Moreover, the problem of enumerating permutations with increasing subsequences can be generalized to other types of pattern avoidance, such as permutations that avoid the pattern 1324 or permutations that are sortable by a stack.

Overall, the count of permutations with at least N increasing elements is a fascinating and important topic in combinatorics and probability theory, with many applications and connections to other areas of mathematics. By studying this problem and its generalizations, we can deepen our understanding of the structure and properties of permutations, and develop new techniques and insights for solving a wide range of mathematical problems.

       

Advertisements

ads