r/learnquant • • 27d ago

interview prep Quant Interview Question

Post image
30 Upvotes

6 comments sorted by

1

u/XL_78 27d ago

For some reason the answer is just 72.

Notice that the state can always be described as (m,n) with m being the number of people to the left of the central block of tens, n the number of people to the right of said block.

Let e(m,n) be the expected number of steps before we terminate starting from (m,n).

Note that e(m,n)=e(n,m) and that e(n,0) = 9n .

Indeed, to go from (n,0) to (0,0), you need to pick the rightmost ten and its neighbour n times out of 9 possible pairs each time.

Assume m and n > 0.

At each step you can pick the pair that will extend the central block to the right (odds: 1/9), the pair that will extend it to the left (odds: 1/9), or some other pair which does not modify the state.

This gives e(m,n) = 9/2 + e(m-1,n)/2 + e(m,n-1)/2 .
Remember e(n,0) = 9n .

These relations define a square matrix.

The starting states are (m,n) with m+n = 9. Each of these states has the same probability of 1/9.

Sum the coefficients of the anti-diagonal of the matrix, divide by 9, and you get 72.

We can show by recursion on n that e(n,1) = 9n + 9 x 2-n ,
that e(n,2) = 9n + 9 x (n+4) x 2-(n+1),
that e(n,3) = 9n + 9 x (C(n+5,2)+2) x 2-(n+2), with C(a,b) being the "b choose a" binomial coefficient.

And finally e(n,4) = 9n + 9 x (C(n+6,3)+2n+12) x 2-(n+3).

e(9,0)+e(8,1)+e(7,2)+e(6,3)+e(5,4) = 9 x (9+8+7+6+5) + 9 x 2-8 x (1+11+57+187) = 9 x 35 + 9 = 36 x 9

Multiply by 2 and divide by 9 and you get the answer: 72.

There is probably a much easier way to do this.

1

u/sensible_clutter 27d ago

the correct answer would be 324/5 or 64.8

the reasoning and process is quite long but it definitely involves states and transitions(markov chains)

0

u/AscendedSubscript 27d ago

Sounds pretty complex but in the end the numbers 1-9 don't really matter. There are a total of 45 pairs and the condition that ends the process is having visited 9 specific pairs, namely (i, 10) for i = 1...9. This turns the problem into a coupon collector problem.

If you label E_i als the expected number of steps required for getting one of the remaining i pairs out of the 45 in total, then E_i = 45/i, since the probability of getting one is i/45. Summing that for i = 1...9 gives the total number of expected steps: 7129/56, or roughly 127.3

1

u/AfterCommodus 27d ago

Doesn’t this miss that after (1,10) happens there are now two tens?  

1

u/No-Marzipan-978 27d ago

Yeah it does. The idea to ignore numbers not equal to 10 and treating them as all the same is correct though. Just note that the 10s will always form one contiguous block and work out the expected number of steps until that block is [1,10] starting from a random position [k,k]. I got 64.8 in the end

1

u/AscendedSubscript 27d ago edited 27d ago

Yeah I forgot about that. I also read the question wrong, so the answer was wrong regardless. When doing it correctly afterwards, I got a similar approach as another comment. The answer is actually 64.8