This entry contains two separate interview-style quantitative/algorithmic questions.
You are standing in a single FIFO queue of 100 customers waiting for service at a checkout counter. Customers are served one at a time, and each service takes the same fixed amount of time (say, one time unit). Positions are numbered 1 (front of the line, served next) through 100 (back of the line).
At time 0, a second identical checkout counter opens. Each of the other 99 customers independently decides to move to the new queue with probability 1/2. All those who choose to move (possibly including you) are randomly ordered in the new queue; every ordering of the movers is equally likely. Both checkout counters start serving at the same time and serve at the same rate (one customer per time unit) from their respective queues.
You are currently at position k in the original queue (1 ≤ k ≤ 100). You must decide once at time 0 whether to stay in the original queue or move to the new one.
k
.
k
is it
better in expectation
(i.e., gives a lower expected waiting time) to switch rather than stay? Give the threshold value(s) of
k
where your preference changes.
You may assume that everyone else’s decision to move or stay is independent of your own and of their position; you are not required to model strategic behavior.
You are given an integer amount n representing a value in cents and you have an unlimited supply of the following coin denominations:
You want to know in how many distinct combinations (multisets) you can make exactly n cents using these coins. The order of coins does not matter; for example, 1 + 5 is the same combination as 5 + 1.
Task:
n
(say up to 10,000), returns the number of distinct combinations of coins whose total value is exactly
n
.
You do not need to print the actual combinations, only their count.