Expected Loops in Randomly Tied Strings

Have you ever wondered about the mathematical properties of tying strings together randomly? Imagine you have a bag with N strings in it. You randomly grab two ends and tie them together until all ends are tied. The question that arises is, what is the expected number of loops? This article explores the combinatorial and dynamic programming approaches to answer this intriguing question.

Understanding the Problem

Each string has two ends, and the process of tying the ends together continues until all ends are bound, forming loops whenever a string is tied to itself. To find the expected number of such loops, we can employ both combinatorial and dynamic programming methods. This article delves into these techniques, offering a comprehensive understanding of the problem.

Combinatorial Approach

Let's begin with the combinatorial method. The total number of ends for N strings is (2N). The goal is to pair these ends randomly to form connections. We can use the double factorial to represent the number of ways to pair these ends:

( left(frac{2N!}{2^N N!}right) )

Defining a Loop

For a specific string, say string (i), the probability that both ends of this string are tied together (forming a loop) is calculated by considering the initial pairing process. When choosing pairs of ends, the probability that both ends of string (i) are tied together is the chance that in the pairing process, we select its two ends first.

Probability of a Loop for One String

The probability (P_i) that string (i) forms a loop can be derived from the total pairing:

( P_i frac{1}{2N - 1} )

This is because when pairing the first end of string (i), there are (2N-1) other ends left, and the chance that we pick the second end of string (i) is (frac{1}{2N-1}).

Expected Number of Loops

Since the loops are independent for each string, the expected number of loops (E[L]) is:

( E[L] N cdot P_i N cdot frac{1}{2N - 1} )

Simplifying this, we obtain:

( E[L] frac{N}{2N - 1} )

Dynamic Programming Solution

Another method to solve this problem is through dynamic programming. In this approach, you compute the probability of having used (i) strings and formed (j) loops. Call this probability (p_{ij}).

The recurrence relation for dynamic programming can be defined as:

( p_{ij} p_{i-1,j} frac{2}{2N - i} p_{i-1,j-1} )

This relation accounts for the probability of forming a loop with the current tie or not. We can then sum (p_{Nj}) for all (j) to get the expected value.

Conclusion

The expected number of loops when tying (N) strings together is given by the formula:

( boxed{frac{N}{2N - 1}} )

Both combinatorial and dynamic programming methods provide valuable insights into this problem, helping us understand the probabilistic nature of randomly tying strings together.