The Combinatorics of Boarding an Airplane

I’ve spent a lot of time at airports recently. And whenever I’m at an airport I find myself thinking about combinatorial problems having to do with airplanes. While flying from SFO to BOS recently, I stumbled across something I found really surprising.

Suppose {n} people board a plane in a random order. Each person has a seat number assigned to them, and whenever someone gets to their seat, they pause for a moment to put their luggage in the overhead bin.

airplane

Whenever someone is pausing for their luggage, they prevent anyone in back of them from passing. Suppose that it takes each person time {w} to walk by a given seat, and time {p \gg w} to put away their luggage once they get to their seat. The question is:

How long will it take for everyone to sit down?

In the worst case the passengers are arranged in decreasing numerical order. This means everyone will have to wait on everyone in front of them, and boarding will take time roughly {n \cdot p}. If, on the other hand, the passengers arrive in the correct (increasing) order, then they’ll each be able to walk straight to their seats, boarding in time {n \cdot w + p}.

But what if the passengers arrive in a random order? Then how much parallelism do we get?

The answer, as it turns out, is quite a lot. In fact, the expected time to board the plane will be

\displaystyle \Theta(n \cdot w + \sqrt{n} \cdot p).

This has some pretty weird consequences. For example, it means that for any fixed {w} and {p}, and for a large enough plane-size {n}, the boarding time will become dominated by the time necessary to walk down to the end of the plane. The time spent waiting on people to put their luggage overhead becomes a non-issue!

A Simplifying Assumption:  To make our analysis easier, we’ll make a simplifying assumption that turns out not to affect the outcome of the analysis. In particular, we’ll treat each of the passengers as though they don’t take any space in the aisle. For example, if one passenger is paused at seat i, and there are there are some passengers waiting behind him that want to get past seat i, then that won’t stop the passenger behind them from getting to seat i - 1.

On top of this, we’re already making the simplifying assumption that each row has only one seat. It turns out that both of these assumptions can be removed without changing the end result. I’ll talk about this more at the end of the post.

The Combinatorics:  The key insight to analyze the algorithm is this: Think of the people as a permutation of seat numbers. If the longest decreasing subsequence in the line of people has length {d}, then it turns out the time to board the plane will be within a factor of two of {n \cdot w + d \cdot p}.

To see this, consider some person {x_1} as they walk to their seat. Let {x_2} be the final person on whom {x_1} waits before {x_1} gets to their seat. Then the total time {x_1} spends waiting on others will be at most {p} greater than the total time that {x_2} spends waiting on others. Similarly there is some person {x_3} who is the last person on whom {x_2} waits; and {x_2} spends at most {p} time more in total waiting than does {x_3}. Continuing like this, we can find a subsequence of people

\displaystyle x_1, x_2, x_3, \ldots, x_k

such that the right-most person {x_k} in the sequence doesn’t have to wait at all, and such that each person {x_i} spends at most {p} longer than {x_{i + 1}} waiting. This means that our original person {x_1} spends time at most {k \cdot p} waiting on others.

The sequence of people {x_1, x_2,x_3, \ldots, x_k} also has the property that their seat numbers are in decreasing order. So what we’ve really shown is that if {d} is the length of the longest decreasing subsequence in the permutation of people, then no person will have to wait for time more than {d \cdot p}, and everyone will have boarded after time {n \cdot w + d \cdot p}.

On the other hand, it’s not hard to see that the left-most person in the length-{d} decreasing sequence will require time at least {d \cdot p} to board the plane; and that the left-most person in the entire line will require time at least {n \cdot w} to board. This means that the true boarding time will be within a factor of two of {n \cdot w + d \cdot p}.

So the real question becomes: On average, how large is {d}, the length of the longest decreasing subsequence in a random permutation?

Bounding the longest decreasing subsequence: We’ll start by considering a different question. For a given length {k}, how many different decreasing subsequences of length {k} should we expect in our permutation? (We count two subsequences as different even if they differ in only a single element.)

This is easy to compute by linearity of expectation: Each {k}-element subsequence has a {1/k!} probability of being in decreasing order. And there are {\binom{n}{k}} different {k}-element subsequences. So the expected number of decreasing subsequences is

\displaystyle \frac{\binom{n}{k}}{k!} = \frac{n \cdot (n - 1) \cdots (n - k + 1)}{k! \cdot k!}.

A useful fact about {k!} is that it’s at least as large as {(k / 3)^k}. So the expected number of decreasing {k}-element subsequences is at most

\displaystyle \frac{n^k}{(k^2 / 9)^k}.

When {k = 6\sqrt{n}}, this reduces to at most {\frac{1}{4^k} = \frac{1}{4^{6 \sqrt{n}}}}.

Of course, if the expected number of {6\sqrt{n}}-element decreasing subsequences is so small, then so is the probability of any such subsequence appearing.

So with extremely high probability, no decreasing subsequence will be of length more than {O(\sqrt{n})}. And this implies that the expected length is also at most {O(\sqrt{n})}.

What about a lower bound? We’ve just shown that the expected length of the longest decreasing subsequence is at most {O(\sqrt{n})}. But is that tight?

For this, we can use a classical result from permutation combinatorics. The Erdös-Szekeres Theorem says that any permutation of length {n} must either contain either a decreasing or an increasing subsequence of length {\sqrt{n}}. For a random permutation, this means that with probability at least {1/2}, there will be a decreasing subsequence of length {\sqrt{n}}.  So the expected length of the longest decreasing subsequence is at least \sqrt{n}/2.

The full version of the problem:  Near the beginning of the post I mentioned we were making two assumptions: (1) That passengers don’t take up any space in the aisle; and (2) that each row has a single seat.

Removing these assumptions makes the problem considerably harder. But it turns out the end conclusion is basically the same. A 2009 math paper on the topic analyzed the problem in its full complexity, and found that as long as each person takes up roughly one row worth of space in the aisle, and the number of seats in each row is constant,  the boarding time remains

\displaystyle \Theta(n \cdot w + \sqrt{n} \cdot p).

 

 

Advertisements

Published by

William Kuszmaul

I am an MIT Ph.D. student in the computer science department. My research focuses on algorithms and combinatorics.

One thought on “The Combinatorics of Boarding an Airplane”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s