Suppose that we are given $n$ records, $R_{1}, R_{2}, \ldots, R_{n} .$ The records are kept in some order. The cost of accessing the $j$ th record in the order is $j$. Thus, if we had four records ordered as $R_{2}, R_{4}, R_{3}, R_{1}$, then the cost of accessing $R_{4}$ would be 2 and the cost of accessing $R_{1}$ would be 4 .
Suppose further that, at each step, record $R_{j}$ is accessed with probability $p_{j}$, with each step being independent of other steps. If we knew the values of the $p_{j}$ in advance, we would keep the $R_{j}$ in decreasing order with respect to $p_{j}$. But if we don't know the $p_{j}$ in advance, we might use the "move to front" heuristic: at each step, put the record that was accessed at the front of the list. We assume that moving the record can be done with no cost and that all other records remain in the same order. For example, if the order was $R_{2}, R_{4}, R_{3}, R_{1}$ before $R_{3}$ was accessed, then the order at the next step would be $R_{3}, R_{2}, R_{4}, R_{1}$.
In this setting, the order of the records can be thought of as the state of a Markov chain. Give the stationary distribution of this chain. Also, let $X_{k}$ be the cost for accessing the $k$ th requested record. Determine an expression for $\lim _{k \rightarrow \infty} \mathbf{E}\left[X_{k}\right]$. Your expression should be easily computable in time that is polynomial in $n$, given the $p_{\jmath}$.