# 1. Increasing subsequences

Consider a random permutation of the numbers 1..2n. Suppose we take the subsequence consisting of the 1st, 3rd, 5th, etc. numbers in this sequence.

- What is the probability that this subsequence is increasing?
- What is the probability that this subsequence and the subsequence consisting of the 2nd, 4th, 6th, etc. cards are both increasing?

## 1.1. Solution

- To produce a permutation on 2n numbers where the odd-position subsequence is increasing, we can first choose which n of the 2n numbers go in the odd-position sequence, and then choose an ordering for the even-position numbers (there is only one choice for the order of the odd-position numbers). This gives (2n choose n)*n! sequences out of (2n)! total sequences, for a probability of (2n choose n)*n! / (2n!) = (2n!)*n!/(n!n!(2n!)) = 1/(n!).
Now we just have to pick which numbers go in which subsequence: the probability that both subsequences are increasing is (2n choose n)/(2n!) = (2n!)/(n!n!(2n!)) = 1/(n!)

^{2}.

# 2. Inversions

An **inversion** in a permutation p of the numbers 1..n is a pair of positions i < j with p_{i} > p_{j}. For example, 123 has no inversions, 312 has two inversions (31 and 32) and 321 has three inversions (32, 31, and 21).

- Compute the expected number of inversions X in a random permutation on 1..n. (Hint: consider a single pair of positions and then use linearity of expectations.)
- Compute the variance of X.

## 2.1. Solution

For each i < j, let X

_{ij}be the indicator variable that is 1 iff there is an inversion at positions i and j. It is immediate from symmetry that E[X_{ij}] = 1/2 (more technical argument: there is a bijection between permutations setting X_{ij}=1 and permutations setting X_{ij}= 0, defined by swapping p_{i}with p_{j}and leaving everything else in place, so the sizes of the two sets of permutations are equal). So E[X] = ∑_{i<j}E[X_{ij}] = (n choose 2)/2 = n(n-1)/4.This is trickier. We will still use the variables X

_{ij}, each of which has Var[X_{ij}] = E[(X_{ij})^{2}] - (EX_{ij})^{2}= 1/2 - 1/4 = 1/4. Now we can compute Var[X] = Var[∑X_{ij}] = ∑ Var[X_{ij}] + 2 ∑_{{ij kl}}Cov(X_{ij}, X_{kl}). The first sum is easy: it's just (1/4)(n choose 2). The last part is messier. Observe first that if there is no overlap between ij and kl, then X_{ij}and X_{kl}are independent, as the (uniform random) choice of which way to flip p_{i}and p_{j}has no effect on the similarly random choice of which way to flip p_{k}and p_{l}. So the only place where we might get nonzero covariance is where ij and kl overlap. There are several cases. Below, we assume without loss of generality that i <= k:The overlap is in the first position: i=k. Then E[X

_{ij}X_{il}] = Pr[p_{i}> p_{j}and p_{i}> p_{k}]. There are 2 permutations of the three values that make this work, since p_{i}must be biggest but the other two can be ordered however we like. This gives Cov(X_{ij}, X_{il}) = 2/6 - 1/4 = 1/12. There are (n choose 3) ways to get this case. Having picked a triplet {a,b,c} we must make i=a but have two choices for which of a,b to make j,l; however, these two choices give the same pair {ij,il}.The overlap is in the middle position: j=k. Then E[X

_{ij}X_{jl}] = Pr[p_{i}> p_{j}> p_{l}] = 1/(3!) = 1/6, and Cov(X_{ij}, X_{jl}) = 1/6 - (1/2)^{2}= 1/6 - 1/4 = -1/12. There are (n choose 3) ways to get this case. Note that the case i=l is equivalent and so doesn't add any cases.The overlap is in the last position: j=l. Then E[X

_{ij}X_{kj}] = Pr[p_{i}> p_{j}and p_{k}> p_{j}]. This is symmetric to the i=k case and Cov(X_{ij}, X_{kj}) = 1/12. There are (n choose 3) ways to get this case.

# 3. A deck of cards

A dealer constructs a deck of cards by choosing a number X between 0 and n uniformly at random (i.e., so that each possible value occurs with probability 1/(n+1)), and then putting in X red cards and n-X black cards. The dealer then shuffles the deck, obtaining a uniform random permutation of the n cards.

Suppose that the dealer turns over the first card and it's black. Conditioned on this event:

- What is the probability that none of the cards in the deck are red?
What is the probability that the next card in the deck is red? (Assume in this case that n >= 2.)

- What is the expected value of X, the number of red cards in the deck?

It may be useful for some of these cases to recall the formulas

## 3.1. Solution

We'll let B be the event that the first card is black.

We want Pr[X=0|B] = Pr[X=0 and B]/Pr[B] = Pr[X=0]/Pr[B], where the equation holds because X=0 implies that B occurs. To compute Pr[X=0], observe that all n+1 possible values of X are equally likely, so P[X=0] = 1/(n+1). For Pr[B], the direct way is to sum Pr[B|X=i]Pr[X=i] over all values of i. This gives 1/(n+1) ∑

_{i=0}^{n}(n-i)/n = 1/(n+1) ∑_{i=0}^{n}i/n = (1/(n(n+1)))*((n(n+1))/2) = 1/2. So we get Pr[X=0|B] = (1/(n+1))/(1/2) = 2/(n+1).Let R be the event that the second card is red. Now we want Pr[R|B] = Pr[R and B]/Pr[B]. We've already computed Pr[B] = 1/2. To compute Pr[R and B], again we'll sum over cases: Pr[R and B] = ∑ Pr[R and B|X=i] Pr[X=i] = 1/(n+1) ∑

_{i=0}^{n}((n-i)/n) * (i/(n-1)) = 1/((n+1)(n)(n-1)) ∑_{i=0}^{n}(n-i)*i = 1/((n+1)(n)(n-1)) [n^{2}(n+1)/2 - ∑_{i=0}^{n}i^{2}] = 1/((n+1)(n)(n-1)) [n^{2}(n+1)/2 - n(n+1)(2n+1)/6] = 1/(6n(n-1)) [3n^{2}- n(2n+1] = (n^{2}- n)/(6(n^{2}-n)) = 1/6. Dividing Pr[R and B] by Pr[B] then gives Pr[R|B] = (1/6)/(1/2) = 1/3.Now we want E[X|B] = ∑

_{x}x Pr[X=x|B]. So let's start by computing Pr[X=x|B]; this is Pr[X=x and B]/Pr[B]. For the numerator we have Pr[X=x and B] = Pr[X=x] * Pr[B|X=x] = (1/(n+1)) * (n-x)/n = (n-x)/(n(n+1)). So Pr[X=x and B] is just 2(n-x)/(n(n+1)). Now we can compute ∑_{x}x Pr[X=x|B] = ∑_{x}2x(n-x)/(n(n+1)) = (2/(n(n+1))) ∑_{x=0}^{n}(xn - x^{2}) = (2/(n(n+1))) [n^{2}(n+1)/2 - n(n+1)(2n+1)/6] = (1/3)[3n - (2n+1)] = (n-1)/3.

# 4. Some related relations

Consider the binary relation R on sets given by R = { (A,B) : there exists an injection f:A->B }.^{1}

- Show that R is reflexive.
- Show that R is transitive.
- Prove or disprove: R is a partial order.
Show that R is a

**refinement**of the usual subset relation, in the sense that if A⊆B, then A R B holds.

## 4.1. Solution

- xRx for any x since the indentity function fa=a is an injection from x to x.
If xRy and yRz we have injections f:x->y and g:y->z. Then gf:x->z is an injection, since if gfa = gfa', we have fa=fa' and thus a=a'.

R is not a partial order, since it is not antisymmetric: we have for example {

`1}R{2} and {2}R{``1} but {``1} != {2}.`Let f(a) = a, then f:A->B is an injection when A⊆B.

Technically, if R ranges over all sets, it's too big to be a set itself. If this worries you, assume that R is restricted to some very large universe of sets. (1)