Lucky Cars and Lucky Spots in Parking Functions

Steve Butler, Kimberly Hadaway, Victoria Lenius, Preston Martens, and

Marshall Moats Department of Mathematics Iowa State University Ames, IA 50011 USA

                  butler@iastate.edu
                   kph3@iastate.edu
                  vlenius@iastate.edu
                  pmart29@iastate.edu
                  mgmoats@iastate.edu

Abstract

Parking functions correspond with preferences of n cars which enter sequentially to park on a one-way street where (1) each car parks in the first available spot greater than or equal to its preference and (2) all cars successfully park. When a car parks in its preferred spot then the corresponding car and corresponding spot are deemed “lucky”. This paper looks briefly at lucky cars which have previously been studied and in simple cases can be understood by a generalization of a result due to Pollak. We also consider lucky spots where the situation is more complex and not previously studied. Probabilities and asymptotics for lucky spots are given for the first few spots on the one-way street. We close with an exploration of the special cases when cars enter the one-way street in either weakly-increasing or weakly-decreasing order of their preferences.

1 Introduction

Consider a one-way street with n available parking spots labeled 1, 2, …, n (where 1 is at the start and n is at the end). There are n cars which sequentially enter to park on this street; each car with its own preference on where to park. As each car enters, it first goes to its preferred spot. If this spot is available, it parks; otherwise, the car moves forwards and parks in the first available spot it finds (if such a spot exists). If the car reaches the end of the street and fails to park, then it drives away. An example of this process unfolding is shown in Figure 1 where the preferences of the cars (in order) to park are (2, 4, 2, 3, 1).

1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 3 2 4 2 1 3 2 4 2 1 3 2 4 2 1 3 2 4 2 1 3 2 4 2 1 3 2 4 2

Figure 1: An example of the parking process with preferences (2, 4, 2, 3, 1).

Definition 1. A parking function of 1, 2, …, n is a set of preferences for the n cars such that every car is able to park in a one-way street with n labeled spots given that each car parks in the first available spot coming on or after its preference.

Parking functions are well studied objects with connections to a variety of topics in enumerative combinatorics; more informatin can be found in a survey by Yan [10, pp. 835– 893]. Many variations and additional statistics about parking functions have been considered; this paper focuses on lucky cars and lucky spots. The notion of “lucky” cars comes from the work of Gessel and Seo [4].)

Definition 2. Given a parking function, a car is called a lucky car if it is able to park in its preferred spot. Similarly, a spot is called a lucky spot if it is parked in by a car which prefers that spot.

By way of example, for the parking function illustrated in Figure 1 the first, second, and fifth cars are lucky. For the same parking function, the first second, and fourth spots are lucky. In general, the indices for lucky cars and lucky spots do not have to agree. However, we do have the following observation.

Observation 3. For a parking function, the number of lucky cars is equal to the number of lucky spots. In particular, the moments for the probability distributions for lucky cars and lucky spots are the same.

The paper proceeds as follows. In Section 2, we discuss a generalization of Pollak and change it for the setting of lucky cars where we show how to compute moments. In Section 3, we then give results about lucky cars and lucky spots. In particular, we give the probability the i-th car is lucky for all i and that the the j-th spot is lucky for 1 ≤ j ≤ 5 and j = n. Finally, in Section 4, we consider the problem of lucky cars and spots when the cars enter to park in the one-way street with either weakly-increasing or weakly-decreasing preferences.

2 A generalization of a result of Pollak

One of the earliest and most well-known results on parking functions is that the number of parking functions is (n+1)^{n−1}. This result is frequently attributed to Pollak (communicated in a paper of Riordan [6]). The proof readily generalizes to handle additional assumptions on which cars are lucky and which are unlucky (an unlucky car is a car which does not park in its preferred space). In the proof below, the case L = U = ∅ reduces to Pollak’s original result and proof.

Theorem 4. Let L, U ⊆ [n] = {1, 2, …, n} with L ∩ U = ∅. Then, the number of parking functions where the cars in positions in L park in their preferred spot, the cars in positions in U do not park in their preferred spot, and the remaining cars have no restrictions is

( ∏_{i∈L}(n + 2 − i))( ∏_{i∈U}(i − 1))(n + 1)^{n−|L|−|U|−1}.

Proof. We add an extra spot, n + 1, and arrange the spots sequentially in a circle (i.e., treating spots as modulo n + 1). Cars can now prefer any spot on the circle including n + 1, and instead of exiting, cars continue around the circle until a spot is found. Since there are n cars and n + 1 spots, all cars can park.

We now consider what happens with the i-th car. If i ∈ L, then i cannot prefer a spot that has already been taken, which gives n+1−(i−1) = n+2−i options to choose from. If i ∈ U, then i must prefer one of the spots that has already been taken, giving i−1 options to choose from. Finally, if i ∉ L ∪ U, then there are n + 1 options to choose from. Importantly, the number of options available does not depend on the choices made by the previous cars. Thus, the number of parking functions on the circle is given by

( ∏_{i∈L}(n + 2 − i))( ∏_{i∈U}(i − 1))(n + 1)^{n−|L|−|U|}.

We can naturally group the parking functions we have created into groups of size n + 1 where we increase all choices by a fixed amount, modulo n + 1. This uniform shifting does not change which cars are lucky/unlucky. For each of our groups there is exactly one representative which avoids n + 1 (since the parking results are all cyclic shifts). We are interested in the parking functions which avoid n + 1 (i.e., no car prefers n + 1 and no “exit” occurs from the first n spots). Hence, we can conclude that 1/(n + 1) fraction of all the parking functions on the circle are our desired parking functions. Multiplying the product above by this factor gives our desired count.

We can count the number of parking functions associated with a specific assignment of lucky/unlucky to the cars. In the other direction, we can also count the the total number of times that we have exactly k lucky cars, expressed as coefficients of a polynomial. This is done with the following result.

Corollary 5. Let c_{k} be the number of parking functions of 1, 2, …, n where there are exactly k lucky cars. Then,

f(x) = \frac{1}{n + 1} ∏_{i=1}^{n} ((n + 2 − i)x + (i − 1)) = ∑_{k=1}^{n} c_{k}x^{k}.

Proof. When multiplying out the n linear terms in the product, we end up with 2^{n} parts, where each part corresponds with a lucky/unlucky assignment. Using Theorem 4, the i-th car being lucky contributes a term of (n + 2 − i) while being unlucky contributes a term of (i − 1), i.e., the x terms in the product correspond with the car being lucky and the constant terms with the car being unlucky. Hence, in the full expansion (including the term 1/(n + 1) in the front), the coefficient of x^{k} is the total number of parking functions which have k cars which are lucky.

We note the function f(x) appeared in work of Gessel and Seo [4] in relation to lucky parking functions; Diaconis and Hicks [2], Durmić et al. [3], and Novelli and Thibon [5] also have work in this area.

We can use this function together with the product rule for derivatives from calculus to find expressions for the c_{k}. We have

c_{k} = \frac{f^{(k)}(0)}{k!} = \frac{1}{n + 1} ∑_{\begin{matrix}S⊆[n] \\ |S|=k \end{matrix}} ( ∏_{i∈S}(n + 2 − i))( ∏_{i∉S}(i − 1)),  (1)

where the elements of S correspond to terms we differentiated and the elements not in S are terms where we did not differentiate. The k! cancels with the k! coming from the product rule as there are k! ways that the order of the derivatives could have occurred. It is straightforward by Equation (1), or directly, to show that c_{1} = (n − 1)! and c_{n} = n!. Using (1) it can also be shown that

c_{2} = (n + 1)(n − 1)!H_{n−1} − (n − 1)(n − 1)! and c_{n−1} = (n + 1)!H_{n} − 2n·n!, where H_{n} = \frac{1}{1} +⋯+ \frac{1}{n} is the n-th harmonic number. (We note c_{n−1} are also the second-order Eulerian numbers ⟨⟨{n \atop n−2}⟩⟩; see \underline{A002538} in the OEIS [8].)

The preceding looks at what happens when we look at the various derivatives of f(x) at x = 0. We also gain information by looking at these derivatives at x = 1.

Proposition 6. Let X be the random variable for the number of lucky cars for a parking function. Then, E(X(X − 1) ⋯ (X − (ℓ − 1))) = \frac{1}{(n+1)^{n−1}} f^{(ℓ)}(1).

Proof. Let p_{ℓ} = c_{ℓ}/(n + 1)^{n−1} be the probability that there are ℓ lucky cars. Then, taking the derivative and evaluating at x = 1 we have

\frac{1}{(n + 1)^{n−1}} f^{(ℓ)}(1) = ∑_{k=1}^{n} k(k − 1) ⋯ (k − (ℓ − 1))p_{k}
= E(X(X − 1) ⋯ (X − (ℓ − 1))).

With the preceding proposition, we can compute various moments. As an example, we have that the expected number of lucky cars, i.e., the mean, is

μ = E(X) = \frac{1}{(n + 1)^{n}} \frac{d}{dx}( ∏_{i=1}^{n} ((n + 2 − i)x + (i − 1)))|_{x=1}

= \frac{1}{(n + 1)^{n}} ∑_{i=1}^{n}(n + 2 − i)(n + 1)^{n−1} = \frac{1}{n + 1} ∑_{i=1}^{n}(n + 2 − i)

= \frac{1}{n + 1}(n(n + 2) − \frac{n(n + 1)}{2}) = \frac{n(n + 3)}{2(n + 1)}.

With a bit more work, one can also show

σ = \sqrt{\frac{(n − 1)n(n + 4)}{6(n + 1)^{2}}},

where σ^{2} = E(X^{2}) − (E(X))^{2} is the variance. We leave the details as an exercise for the interested reader (see also the references [2, 7]).

3 Lucky cars and lucky spots

First, we introduce a parameter that takes into consideration both spots and cars.

Definition 7. Given 1 ≤ i, j ≤ n, let q_{n}(i, j) denote the number of parking functions of 1, 2, …, n where the i-th car prefers the j-th spot and the i-th car is lucky.

\begin{matrix}i j & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\ 1 & 65536 & 48729 & 40953 & 35328 & 30208 & 24583 & 16807 \\ 2 & 53248 & 41243 & 35627 & 31502 & 27662 & 23287 & 16807 \\ 3 & 43008 & 32728 & 29869 & 27406 & 24924 & 21866 & 16807 \\ 4 & 34496 & 24660 & 22967 & 22788 & 21866 & 20256 & 16807 \\ 5 & 27440 & 17712 & 16055 & 16608 & 18138 & 18312 & 16807 \\ 6 & 21609 & 12096 & 10125 & 10240 & 11875 & 15552 & 16807 \\ 7 & 16807 & 7776 & 5625 & 5120 & 5625 & 7776 & 16807 \end{matrix}

Table 1: The number of parking functions of 1, …, 7, where the i-th car prefers and parks in the j-th spot, this is denoted as q_{7}(i, j). The row sums correspond with when the i-th car is lucky; the column sums correspond with when the j-th spot is lucky.

As an example, the data for q_{7}(i, j) is provided in Table 1. Looking at the entries, they do not appear to always be well-behaved; for instance, the rows are not always monotonic. However, the borders of the data (e.g., the first/last car/spot) do have “nice” behavior (insofar as there are formulas to compute them).

Before producing the formulas for the borders (bottom, top, right, and left), we find it convenient to give a count for partial parking functions (e.g., preferences for cars where all cars park yet not all spots need to be filled). This is again another generalization of Pollak, and the proof follows the same argument as [6] (see also Theorem 4); so we omit the proof here.

Proposition 8. Let s ≤ t. The number of preferences for s cars wanting to park in a oneway street with t available spots so that all cars successfully park in an available sport on or after their preference is (t + 1 − s)(t + 1)^{s−1}.

Lemma 9. The values q_{n}(i, j) satisfy the following:

q_{n}(n, j) = ({n−1 \atop j−1})j^{j−2}(n − j + 1)^{n−j−1},  (Bottom)
q_{n}(1, j) = ∑_{k=j}^{n} ({n−1 \atop k−1})k^{k−2}(n − k + 1)^{n−k−1},  (Top)
q_{n}(i, n) = n^{n−2}, and  (Right)
q_{n}(i, 1) = (n + 1)^{n−i−1}n^{i−2}(2n + 1 − i).  (Left)

Proof. (Bottom) The case of q_{n}(n, j) corresponds to parking functions where the last entry is j and the preceding n − 1 terms result in having no car parked in j. These are formed by taking a parking function on 1, 2, …, j − 1 (which can be done in j^{j−2} ways), a parking function on j + 1, j + 2, …, n (which can be done in (n − j + 1)^{n−j−1} ways), and then interleaving them in all possible ways (which can be done in ({n−1 \atop j−1}) ways). (This is \underline{A298594} in the OEIS [8].) We note in passing that these entries show the last car is more likely to be lucky if its preference is either near the start or the end of the street than if its preference is in the middle of the street.

(Top) The case of q_{n}(1, j) corresponds to parking functions that start with j. If we skip the first car and use the remainder of the parking function, then the result is an open space in one of the locations from j through n, and we call that open space k. Each such case was handled in the previous scenario (i.e., union of two parking functions with a gap between), so we sum the previous result from j to n. (This is \underline{A298592} in the OEIS [8].)

(Right) The case of q_{n}(i, n) corresponds to parking functions with n in the i-th slot. By the nature of parking functions, there can be at most one n among the preferences, and if there is a car which prefers n, then the remaining cars can never move into the n-th spot. This means that the remaining n − 1 slots must form a parking function of 1, 2, …, n − 1 which can be done in n^{n−2} ways.

(Left) The case of q_{n}(i, 1) corresponds to parking functions where the first occurrence of 1 is in slot i. To build such a parking function, we first place 1 in slot i. We then can place as many additional 1s in slots i+1, i+2, …, n as we want; let k be the number of additional cars with preference 1 with 0 ≤ k ≤ n − i, where for each k, there are ({n−i \atop k}) ways to pick which of the cars from i + 1, i + 2, …, n prefer spot 1. Finally, the remaining n − k − 1 slots are filled up by cars whose preferences come from 2, 3, …, n, and when restricted to only those cars, all cars park; by Proposition 8, with s = n − k − 1 and t = n − 1 there are (k + 1)n^{n−k−2} such preferences. Putting this together and using the binomial theorem (e.g., ∑_{k} x^{k}\binom{m}{k} = (1 + x)^{m} and ∑_{k} kx^{k−1}\binom{m}{k} = m(1 + x)^{m−1}), we have

∑_{k=0}^{n−i} ({n−i \atop k})(k + 1)n^{n−k−2} = n^{n−3} ∑_{k=0}^{n−i} k(\frac{1}{n})^{k−1}({n−i \atop k}) + n^{n−2} ∑_{k=0}^{n−i} (\frac{1}{n})^{k}({n−i \atop k})
= n^{n−3}(n − i)(1 + \frac{1}{n})^{n−i−1} + n^{n−2}(1 + \frac{1}{n})^{n−i}
= (n + 1)^{n−i−1}n^{i−2}((n − i) + (n + 1)).

In the last case, we did not need to worry about how the choices for where we put the 1s interacted with the choice of the preferences of the remaining cars. This is because every rearrangement of parking functions is always a parking function (shown previously by Yan [10, pp. 835–893]), and therefore, we can have all of the cars that prefer 1 park at the end. In this case, we see that they fill in all of the spots which remain unoccupied after the other cars park.

We now consider the row and column sums for the q_{n}(i, j). By applying Theorem 4, with L = {i} and U = ∅, we have the following for the i-th row sum which corresponds with the i-th car being lucky.

Corollary 10. The number of parking functions of 1, 2, …, n for which the i-th car is lucky is

∑_{j=1}^{n} q_{n}(i, j) = (n + 2 − i)(n + 1)^{n−2} = (1 − \frac{i−1}{n+1})(n + 1)^{n−1}.

Thus, the probability that the i-th car is lucky is 1 − \frac{i−1}{n+1}. If we fix a value of i and let n get large, then that probability goes to 1. In other words, when there are many cars to park, it almost always happens that the early cars get their preferred spots. Similarly, the end cars almost never get their preferred spots.

For the column sums, the situation is starkly different. In Table 2, we have produced the data for the column sums for some small values of j and n, and this triangle appears as \underline{A374756} in the OEIS [8].

n j  1  2  3  4  5  6
1  1
2  3  2
3  16  11  9
4  125  87  74  64
5  1296  908  783  708  625
6  16807  11824  10266  9421  8733  7776
7  262144  184944  161221  148992  140298  131632
8  4782969  3381341  2955366  2742090  2600879  2480787
9  100000000 70805696 61999923 57671104 54921875 52779840
10  2357947691 1671605646 1465709426 1365730231 1303885965 1258181726

Table 2: The number of parking functions for n cars where the j-th spot is lucky for 1 ≤ j ≤ 6 and for 1 ≤ n ≤ 10.

Since there are no spots before 1, then the only car that can park in spot 1 must prefer spot 1, meaning that spot 1 is always lucky. We have the following.

Observation 11. The number of parking functions of 1, 2, …, n for which the first spot is lucky is

∑_{i=1}^{n} q_{n}(i, 1) = (n + 1)^{n−1}.

We now turn to the sum of the entries in the second column, in other words, the number of times the second spot is lucky.

Theorem 12. The number of parking functions of 1, 2, …, n for which the second spot is lucky is

∑_{i=1}^{n} q_{n}(i, 2) = \frac{3}{4}(n + 1)^{n−1} − \frac{1}{4}(n − 1)^{n−1}.

Proof. Let ℓ denote the number of cars that prefer 1 or 2 (so 2 ≤ ℓ ≤ n), and let k denote the number of cars that prefer 1 (so 1 ≤ k ≤ ℓ − 1). For each choice of k and ℓ, we do the following:

• Choose which of the cars prefer either 1 or 2, this can be done in ({n \atop ℓ}) ways.

• For each choice that we have just made, now select how the 1s and the 2s are relatively placed. The key observation is that the first 2 must happen before two 1s have occurred. (If not, the second spot cannot be lucky.) We can do this by looking at all ways to position the 1s (which is ({ℓ \atop k})) and then removing the ways which have two 1s at the start (which is ({ℓ−2 \atop k−2})). Altogether, this can be done in ({ℓ \atop k}) − ({ℓ−2 \atop k−2}) ways.

• Assign the remaining n − ℓ cars to park in positions 3, 4, …, n so that among them there are no exits. Applying Proposition 8 with s = n − ℓ and t = n − 2, we have that this can be done in (ℓ − 1)(n − 1)^{n−ℓ−1} ways.

Putting everything together we have

∑_{i=1}^{n} q_{n}(i, 2) = ∑_{ℓ=2}^{n} ∑_{k=1}^{ℓ−1} \binom{n}{ℓ}(\binom{ℓ}{k} − \binom{ℓ − 2}{k − 2})(ℓ − 1)(n − 1)^{n−ℓ−1}

= (n − 1)^{n−1} ∑_{ℓ=2}^{n}(n − 1)^{−ℓ}(ℓ − 1)\binom{n}{ℓ} ∑_{k=1}^{ℓ−1} (\binom{ℓ}{k} − \binom{ℓ − 2}{k − 2}).

We start with the inner sum:

∑_{k=1}^{ℓ−1} (\binom{ℓ}{k} − \binom{ℓ − 2}{k − 2}) = ( ∑_{k=0}^{ℓ} \binom{ℓ}{k} − 1 − 1) − ( ∑_{k=2}^{ℓ} \binom{ℓ − 2}{k − 2} − 1)
= (2^{ℓ} − 2) − (2^{ℓ−2} − 1) = \frac{3}{4}2^{ℓ} − 1.

Replacing the inner sum and then expanding and separating, the outer sum becomes the following (note that at ℓ = 1 the expression in the sum is 0 and at ℓ = 0 the expression in the sum is \frac{1}{4}):

∑_{ℓ=2}^{n}(n − 1)^{−ℓ}(ℓ − 1)\binom{n}{ℓ}(\frac{3}{4} · 2^{ℓ} − 1) = ∑_{ℓ=0}^{n}(n − 1)^{−ℓ}(ℓ − 1)\binom{n}{ℓ}(\frac{3}{4} · 2^{ℓ} − 1) − \frac{1}{4}

= \frac{3}{4} ∑_{ℓ=0}^{n} ℓ(\frac{2}{n−1})^{ℓ}\binom{n}{ℓ} − \frac{3}{4} ∑_{ℓ=0}^{n} (\frac{2}{n−1})^{ℓ}\binom{n}{ℓ} − ∑_{ℓ=0}^{n} ℓ(\frac{1}{n−1})^{ℓ}\binom{n}{ℓ} + ∑_{ℓ=0}^{n} (\frac{1}{n−1})^{ℓ}\binom{n}{ℓ} − \frac{1}{4}.

These sums can be evaluated by using the binomial theorem and derivative variants (e.g., ∑_{ℓ} x^{ℓ}\binom{m}{ℓ} = (1 + x)^{m} and ∑_{ℓ} ℓx^{ℓ}\binom{m}{ℓ} = mx(1 + x)^{m−1}). The outer sum now becomes the following:

\frac{3}{4}n(\frac{2}{n−1})(\frac{n+1}{n−1})^{n−1} − \frac{3}{4}(\frac{n+1}{n−1})^{n} − n(\frac{1}{n−1})(\frac{n}{n−1})^{n−1} + (\frac{n}{n−1})^{n} − \frac{1}{4}

= \frac{6n(n + 1)^{n−1} − 3(n + 1)^{n} − (n − 1)^{n}}{4(n − 1)^{n}} = \frac{3(n + 1)^{n−1} − (n − 1)^{n−1}}{4(n − 1)^{n−1}} .

Finally, using this expression for the outer sum, we have

∑_{i=1}^{n} q_{n}(i, 2) = (n − 1)^{n−1}(\frac{3(n + 1)^{n−1} − (n − 1)^{n−1}}{4(n − 1)^{n−1}} ) = \frac{3}{4}(n + 1)^{n−1} − \frac{1}{4}(n − 1)^{n−1}.

Before proceeding, we observe that the resulting expression is surprisingly simple. It would be interesting to see if there is a more elegant way to arrive at the same result.

Similar expressions can be found for other column sums, but the case analysis gets more substantial as j increases. As an example, for the third column sum when we restrict to what the 1s and 2s are doing, if it starts as 12, 21, or 11, then the first 3 must occur by the (relative) third term when restricted to 1s, 2s, and 3s. However, if the restriction starts as 22, then the first 3 must occur by the (relative) second term when restricted to 1s, 2s, and 3s (i.e., the first car preferring 2 parks in spot 2, and the second car preferring 2 parks in spot 3 so that the third spot is not parked in by a car which prefers 3).

Carrying out the case analysis and simplifying the resulting sums (e.g., by similar manipulation as above), we have the following expressions for the next few column sums (equivalently, the number of parking functions for which the third, fourth, and fifth spots are lucky):

∑_{i=1}^{n} q_{n}(i, 3) = \frac{2}{3}(n + 1)^{n−1} − \frac{1}{3}(2n − 1)(n − 2)^{n−2}

∑_{i=1}^{n} q_{n}(i, 4) = \frac{5}{8}(n + 1)^{n−1} − \frac{1}{8}(13n^{2} − 26n + 9)(n − 3)^{n−3}

∑_{i=1}^{n} q_{n}(i, 5) = \frac{3}{5}(n + 1)^{n−1} − \frac{1}{30}(118n^{3} − 531n^{2} + 659n − 192)(n − 4)^{n−4}.

Using these expressions, we can also find the asymptotics for how likely it is that the j-th spot is lucky for 1 ≤ j ≤ 5. This is given in Table 3.

A pattern seems to be emerging, which suggests the following conjecture.

Conjecture 13. The number of parking functions where the j-th spot is lucky has the form \frac{j+1}{2j}(n+1)^{n−1} −f_{j}(n)(n−j +1)^{n−j+1} where f_{j}(n) is a polynomial of degree j −2 with rational coefficients. In particular, for some rational r_{j}, the asymptotic probability that the j-th spot is lucky is \frac{j+1}{2j} − r_{j}e^{−j}.

Looking back at Table 2, one might also notice that the diagonal terms (i.e., the n-th column sums) are well-behaved. Indeed, by Lemma 9, we have the following:

Observation 14. The number of parking functions of 1, 2, …, n for which the n-th spot is lucky is

∑_{i=1}^{n} q_{n}(i, n) = ∑_{i=1}^{n} n^{n−2} = n^{n−1}.

j  Exact ρ_{j}  Numerical ρ_{j}
1 1  1.000000…
2  \frac{3}{4} − \frac{1}{4}e^{−2}  0.716166…
3  \frac{2}{3} − \frac{2}{3}e^{−3}  0.633475…
4  \frac{5}{8} − \frac{13}{8}e^{−4}  0.595237…
5  \frac{3}{5} − \frac{59}{15}e^{−5}  0.573497…

Table 3: The asymptotic probability as n → ∞ that the j-th spot is lucky, which is denoted

by ρ_{j} = lim_{n→∞} ((n + 1)^{−(n−1)} ∑_{i=1}^{n} q_{n}(i, j)).

Thus, the probability that the last spot is occupied by a car which prefers the last spot is asymptotically e^{−1} = 0.367879…. By comparison, the probability that the last car parks in its preferred spot is \frac{2}{n+1} → 0.

Question 15. What can be said about the (n − 1)-st column sum, ∑_{i} q_{n}(i, n − 1)? Or more generally, the (n − j)-th column sum, ∑_{i} q_{n}(i, n − j)?

For reference the (n − 1)-st column sums (the sub-diagonal in Table 2) starts with the following values:

3, 11, 74, 708, 8733, 131632, 2342820, 48068672, 1116809255, ….

The authors were not able to find expressions for these sums. Moreover, this sequence (along with columns ≥ 2 in Table 2) has not previously appeared in the OEIS [8]. Thus, they have added these sequences to OEIS [8]: \underline{A372842}, \underline{A372843}, \underline{A372844}, \underline{A372845}, \underline{A374533}, and \underline{A374756}. Moreover, the row sums indicate the number of lucky cars across all parking functions of length n, and this yields another new sequence (now \underline{A375616} in OEIS [8]) whose formula is in terms of other sequences in OEIS. There is still much to be found with regards to lucky spots.

4 Weakly-increasing and weakly-decreasing

We now look at the special cases when the preference of cars are either in weakly-increasing or weakly-decreasing order. It is known that the number of such parking functions in these cases is the n-th Catalan number C_{n} = \frac{1}{n+1} \binom{2n}{n} as shown by Stanley [9, pp. viii+215] and Yan [10, pp. 835–893]. This can be seen by using the classical bijection between such parking functions and Dyck paths which we describe below.

Definition 16. A Dyck path of size n is a path going from (0, 0) to (n, n) consisting of unit north and unit east steps never going below the line y = x.

For the bijection between Dyck paths and weakly-increasing parking functions, start with a Dyck path, and label the columns (spots) from left to right with 1, 2, …, n. Similarly, label the rows (cars) from bottom to top with 1, 2, …, n. To find the preference of the i-th car, go from the right hand side of the row labeled i moving to the left until you hit the Dyck path and go down to read the column label. For example, in Figure 2(a) we go from a Dyck path of size n = 8 to the weakly-increasing parking function (1, 1, 2, 2, 2, 6, 7, 7).

For the bijection of weakly-decreasing parking functions, the only difference is that the rows (cars) are labeled from top to bottom with 1, 2, …, n. For example, in Figure 2(b) we go from a Dyck path of size n = 8 to the weakly-decreasing parking function (7, 7, 6, 2, 2, 2, 1, 1).

Spots Cars 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 Increasing  Spots Cars 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 Decreasing
(a) (1, 1, 2, 2, 2, 6, 7, 7)  (b) (7, 7, 6, 2, 2, 2, 1, 1)

Figure 2: Bijection between a Dyck path and a (a) weakly-increasing parking function, and a (b) weakly-decreasing parking function.

For this discussion, we modify the notation for the previously introduced parameters.

Definition 17. Given 1 ≤ i, j ≤ n, let q_{n}^{i}(i, j) (similarly, q_{n}^{d}(i, j)) denote the number of increasing (similarly, decreasing) parking functions of 1, 2, …, n where the i-th car prefers the j-th spot and the i-th car is lucky.

4.1 Weakly-increasing

When the cars come in weakly-increasing order, the spots in the street fill up in order from 1 through n. This means that the i-th car to enter parks in spot i. In particular, the i-th car is lucky if and only if it prefers spot i. That is, for weakly-increasing parking functions, the i-th car is lucky if and only if the i-th spot is lucky.

In terms of Dyck paths, this corresponds to when the Dyck path comes up off of the line y = x on the left-hand side of the column labelled i. In particular, the Dyck path must be a concatenation of two Dyck paths: one for the first i − 1 columns (which can be done in C_{i−1} ways) and one for the remaining n − i + 1 columns (which can be done in C_{n−i+1} ways). This establishes the following.

Lemma 18. We have that

q_{n}^{i}(i, j) = \begin{cases}C_{i−1}C_{n−i+1}, & if i = j; \\ 0, & else. \end{cases}

In particular, the number of weakly-increasing parking functions of 1, 2, …, n for which the i-th car (spot) is lucky is C_{i−1}C_{n−i+1}.

Corollary 19. The expected number of lucky cars/spots for a random weakly-increasing parking function is \frac{3n}{n+2}.

Proof. The expected number of lucky cars/spots is equivalent to the expected number of times a Dyck path comes off of y = x, or equivalently, the expected number of times the Dyck path returns to y = x. Deutsch [1] previously showed this expected value is \frac{3n}{n+2}.

We note that having the preferences in weakly-increasing order attains the minimum number of lucky cars/spots for a given set of preferences. This can be seen because if the i-th car is lucky for a weakly-increasing parking function, then the first i−1 cars would have wanted to park in the first i−1 spots, while all remaining cars want to park in i or above. In particular, no car which has a preference before or after spot i can park in spot i. Thus, if a spot is lucky in the weakly-increasing order, it is be lucky in every ordering. In other words, for weakly-increasing parking functions, the only spots that are lucky are those which must always be lucky.

4.2 Weakly-decreasing

When the cars come in weakly-decreasing order, then a car is lucky if it parks in a previously unpreferred spot. This can be seen by noting that if a car prefers a previously unpreferred spot, then all preceding cars must have parked further down the street and thus the desired spot is available. In particular, every spot which has at least one car preferring that spot is lucky. This means that the weakly-decreasing order attains the maximum number of lucky cars/spots.

In terms of Dyck paths, the i-th car prefers the j-th and be lucky if and only if the Dyck path contains the sub-path shown in Figure 3. In terms of coordinates of the lattice, this corresponds to the following pair of edges being present in the path:

(j − 1, n − i) → (j − 1, n − i + 1) → (j, n − i + 1).  (2)

In particular, the number of lucky cars/spots corresponds with the number of peaks in the Dyck path. Remark 20. The Narayana numbers N(n, k) = \frac{1}{k} \binom{n−1}{k−1}\binom{n}{k−1} (see \underline{A001263} in the OEIS [8]) count the number of Dyck paths from (0, 0) to (n, n) with exactly k peaks. Equivalently, the Narayana numbers are the number of weakly-decreasing parking functions of 1, 2, …, n with exactly k lucky cars/spots.

\begin{matrix}j \\ i \end{matrix}

Figure 3: Sub-path needed in the Dyck path for a weakly-decreasing parking function having the i-th car prefer the j-th spot and be lucky.

We now work to find q_{n}^{d}(i, j), and we start by counting particular lattice paths.

Lemma 21. For ℓ ≥ k, the number of lattice paths from (0, 0) to (k, ℓ) which stay on or above the line y = x is \frac{ℓ−k+1}{ℓ+1} \binom{k+ℓ}{k}.

Proof. We follow a classic sub-path flipping argument for Dyck paths. We start by noting the total number of paths from (0, 0) to (k, ℓ) is \binom{k+ℓ}{k}, e.g., there are k east steps and ℓ north steps, and thus, we only need to decide which of the k + ℓ steps are east steps.

We now need to remove all paths that go below the line y = x. To count these, we note that there is a first such time that the path hits the line y = x − 1; then, we flip the remainder of the path across the line y = x − 1 to form a path that goes from (0, 0) to (ℓ + 1, k − 1). Note that this can also be reversed for all paths from (0, 0) to (ℓ + 1, k − 1). In particular, there are \binom{(ℓ+1)+(k−1)}{k−1} = \binom{k+ℓ}{k−1} such paths.

Thus, the number of paths is

\binom{k + ℓ}{k} − \binom{k + ℓ}{k − 1} = (1 − \frac{k}{ℓ + 1})\binom{k + ℓ}{k} = \frac{ℓ − k + 1}{ℓ + 1}\binom{k + ℓ}{k}.

Lemma 22. The number of weakly-decreasing parking functions where the i-th car prefers the j-th spot and is lucky is

q_{n}^{d}(i, j) = \begin{cases}\frac{(n − i − j + 2)^{2}}{(n − i + 1)(n − j + 1)}\binom{n − i + j − 1}{j − 1}\binom{n − j + i − 1}{i − 1} & if i + j ≤ n + 1; \\ 0 & else. \end{cases} (3)

Proof. The condition that i + j ≤ n + 1 is needed to ensure the peak occurs above the line y = x.

We can break our Dyck paths which contribute to q_{n}^{d}(i, j) into three parts, namely from (0, 0) up to (j − 1, n − i), then the two steps in Equation (2), and finally from (j, n − i + 1) to (n, n). By symmetry (e.g., flipping across the “anti-diagonal”), this last portion is equivalent to counting the walks that stay above y = x from (0, 0) to (i−1, n−j). Now, apply Lemma 21 to find the counts for the first and last portions of the Dyck path; multiplying then gives the result.

\begin{matrix}i j & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\ 1 & 1 & 6 & 20 & 48 & 90 & 132 & 132 \\ 2 & 6 & 25 & 56 & 84 & 84 & 42 & 0 \\ 3 & 20 & 56 & 81 & 70 & 28 & 0 & 0 \\ 4 & 48 & 84 & 70 & 25 & 0 & 0 & 0 \\ 5 & 90 & 84 & 28 & 0 & 0 & 0 & 0 \\ 6 & 132 & 42 & 0 & 0 & 0 & 0 & 0 \\ 7 & 132 & 0 & 0 & 0 & 0 & 0 & 0 \end{matrix}

Table 4: The number of weakly-decreasing parking functions of 1, …, 7, where the i-th car prefers and parks in the j-th spot, which is denoted as q_{7}^{d}(i, j). The row sums correspond with when the i-th car is lucky; the column sums correspond with when the j-th spot is lucky.

Examining the data in Table 4 for q_{7}^{d}(i, j), we observe symmetry in the entries. This can be seen symbolically by examining Equation (3) which is symmetric in its use of i and j. This can also be seen visually by flipping each Dyck path across the “anti-diagonal” and seeing where the peaks go. As a consequence of the symmetry of q_{n}^{d}(i, j), we have that the number of times the i-th car is lucky is equal to the number of times that the i-th spot is lucky.

Corollary 23. The number of weakly-decreasing parking functions of length n where the j-th spot (car) is lucky is

∑_{i=1}^{n} q_{n}^{d}(i, j) = ∑_{i=1}^{n+1−j} \frac{(n − i − j + 2)^{2}}{(n − i + 1)(n − j + 1)}\binom{n − i + j − 1}{j − 1}\binom{n − j + i − 1}{i − 1}.  (4)

While Equation (4) gives an expression for the number of times the j-th spot (car) is lucky, it is somewhat unwieldy. By approaching the problem of counting from a different direction, we find a more convenient expression (see Equation (5) below). These expressions are thus equal; the authors do not know a direct algebraic proof that establishes their equality.

Theorem 24. The number of weakly-decreasing parking functions of length n where the j-th spot (car) is lucky is

∑_{k=0}^{n−j} C_{n−1−k}C_{k} = ∑_{k=0}^{n−j} \frac{1}{(n − k)(k + 1)}\binom{2(n − 1 − k)}{n − 1 − k}\binom{2k}{k}.  (5)

Before beginning the proof, we note that the numbers which arise in this manner correspond with the entries of \underline{A067323} in the OEIS [8] which come from the Catalan triangle.

Proof. We establish a bijection between P_{n}^{(j)}, a Dyck path of length n where there is a peak on the j-th column, and (Q_{n−1−k}, Q_{k}) an (ordered) pair of Dyck paths of length n − 1 − k and k, respectively, with 0 ≤ k ≤ n − j.

First, note that for P_{n}^{(j)} that there must be at least one north step on the line x = j − 1. Now, let (j − 1, ℓ) be the first point where the P_{n}^{(j)} hits x = j − 1, and let (s, t) be the next point where P_{n}^{(j)} hits the line y = x + ℓ − j + 1.

Let k = s − j. The Dyck path Q_{n−1−k} is formed by concatenating the part of P_{n}^{(j)} from (0, 0) to (j − 1, ℓ) with the part of P_{n}^{(j)} from (s, t) to (n, n). The Dyck path Q_{k} is formed by the part of P_{n}^{(j)} from (j − 1, ℓ + 1) to (s − 1, t). An example of this is illustrated in Figure 4.

This process can be reversed by taking the the Dyck path Q_{n−1−k} and splitting at x = j − 1. We have the first part start at (0, 0), and the second part end at (n, n). We now add a north step out of the first part, and an east step into the second part. Finally, insert the Dyck path Q_{k} to combine these two paths. In order to carry this out it must be that the first Dyck path has to touch the line x = j − 1 which forces 0 ≤ k ≤ n − j.

j↔ ( j,)

Figure 4: Example of a bijection between P_{n}^{(j)} ↔ (Q_{n−1−k}, Q_{k}) for Theorem 24.

Since Equation (5) counts the number of ways to select the two Dyck paths (Q_{n−1−k}, Q_{k}) for 0 ≤ k ≤ n − j, the result follows.

Finally, let us compute the expected number of lucky spots for weakly-decreasing parking functions. As noted earlier, this is the same as the number of preferred spots for a weaklydecreasing parking function.

Theorem 25. For n ≥ 1, the expected number of lucky spots for a weakly-decreasing parking function is \frac{1}{2}(n + 1).

Proof. We use Theorem 24 to count the total number of lucky spots over all weaklydecreasing parking functions of length n to get

∑_{j=1}^{n} ( ∑_{k=0}^{n−j} C_{n−1−k}C_{k}) = ∑_{k=0}^{n−1} ( ∑_{j=1}^{n−k} C_{n−1−k}C_{k}) = ∑_{k=0}^{n−1}(n − k)C_{n−1−k}C_{k}.

As in Stanley’s book [9, pp. viii+215], we recall that the generating function for Catalan numbers is

f(x) = ∑_{n=0}^{∞} C_{n}x^{n} = \frac{1 − \sqrt{1 − 4x}}{2x} and so \frac{d}{dx}(xf(x)) = ∑_{n=0}^{∞} nC_{n−1}x^{n} = \frac{x}{\sqrt{1 − 4x}}.

Putting this together, we have

∑_{n=0}^{∞} ( ∑_{k=0}^{n−1}(n − k)C_{n−1−k}C_{k})x^{n} = ( ∑_{n=0}^{∞} C_{n}x^{n})( ∑_{n=0}^{∞} nC_{n−1}x^{n})

= (\frac{1 − \sqrt{1 − 4x}}{2x})(\frac{x}{\sqrt{1 − 4x}}) = \frac{1}{2\sqrt{1 − 4x}} − \frac{1}{2} = ∑_{n=1}^{∞} \frac{1}{2}\binom{2n}{n}x^{n}.

In particular, the total number of lucky spots is \frac{1}{2} \binom{2n}{n}. On the other hand, the total number of weakly-decreasing parking functions is \frac{1}{n+1} \binom{2n}{n}. Dividing the two terms gives the result.

References

[1] E. Deutsch, Dyck path enumeration, Discrete Math. 204 (1999), 167–202.

[2] P. Diaconis and A. Hicks, Probabilizing parking functions, Adv. in Appl. Math. 89 (2017), 125–155.

[3] I. Durmić, A. Han, P.E. Harris, R. Ribeiro, and M. Yin, Probabilistic parking functions, Arxiv preprint arXiv:2211.00536 [math.CO], November 1 2022. Available at https://

arxiv.org/abs/2211.00536.

[4] I. Gessel and S. Seo, A refinement of Cayley’s formula for trees, Electron. J. Combin. 11 (2004), Paper #27.

[5] J.-C. Novelli and J.-Y. Thibon, Duplicial algebras, parking functions, and Lagrange inversion. In F. Chapoton, F. Fauvet, C. Malvenuto, and J.-Y. Thibon, eds., Algebraic Combinatorics, Resurgence, Moulds and Applications (CARMA). Vol. 1, EMS Publishing House, 2020, pp. 263–290.

[6] J. Riordan, Ballots and trees, J. Combin. Theory 6 (1969), 408–411.

[7] A. Slavík and M. Vestenická, Lucky cars: Expected values and generating functions, Amer. Math. Monthly 131 (2024), 343–348.

[8] N. Sloane and The OEIS Foundation Inc., The on-line encyclopedia of integer sequences,

https://oeis.org/, 2023.

[9] R. Stanley, Catalan Numbers, Cambridge University Press, 2015.

[10] C. Yan, Parking functions. In M. Bóna, ed., Handbook of Enumerative Combinatorics, CRC Press, 2015, pp. 835–893.

2020 Mathematics Subject Classification: Primary 05A15. Keywords: parking function, lucky car, lucky spot, Pollak’s theorem.

(Concerned with sequences \underline{A001263}, \underline{A002538}, \underline{A067323}, \underline{A298592}, \underline{A298594}, \underline{A372842}, \underline{A372843}, \underline{A372844}, \underline{A372845}, \underline{A374533}, \underline{A374756}, and \underline{A375616}.)

Received August 23 2024; revised versions received September 22 2025; October 10 2025; December 19 2025. Published in Journal of Integer Sequences, December 20 2025.

Return to Journal of Integer Sequences home page.