Expectation of number of assignments

75 Views Asked by At

I went to an interview and there was a question that I couldn't solve, I am not $100$% sure about the exact wording, but I think was something like this:

Given $n$ different random numbers $\{a_1, a_2,...,a_n\}$, we want to find the maximum of these numbers. First let $m=a_1$. Then, we compare $m$ to $a_2$, if $m>a_2$, reassign $m$ to be $a_2$, but if $m<a_2$, then $m$ value doesn't change. With the same method, compare $m$ to the rest of the numbers. After we're done comparing all the numbers, $m$ would be the maximum value.

What is the average number of assignments of $m$ to find the maximum of the list?"

P.S - I think that setting $m=a_1$ also counts as one assignment.