Number of ways arrival and departure events happen in a FIFO queue.

18 Views Asked by At

Consider a FIFO queue with an upper bound of queue size $U$. $N$ people already in the queue when this person A arrives at time $t_0$. Now there are $N+1$ people in the queue ($N+1\leq U$). Suppose A is served and leave the queue at time $t_1$. Also in time window $(t_0, t_1)$ a total of $M<U$ other person joins the queue. What is the number of ways the arrival/departure event could happen in time $(t_0, t_1)$?

Here is an example, say $U=5, N=2$ and $M=2$. This is easy because $N+M<U$. All arrival/departure sequences in in time $(t_0, t_1)$ are legit. And the answer is $\binom{4}{2}$. However, if $M$ becomes $3$ then sequence "aaadd" (a for arrival and d for departure) is not allowed, because after the last "a" there are $6$ people in the queue.

What is the solution to this problem in general?