I am looking at part b) of this problem: Problem
Solution with Annotated Question
I don't understand how to get from the underlined part to the end of the arrow? What's the logic or reasoning here? Is it that the max number of tests for the smaller sub-group made up of $k$ individuals is $(n/k) * (k+1)$? If so, why would we subtract the total minimum (n) tests for the entire group from that number? I'm mostly confused because I thought expected value was the weighted probability of each possible value, reflected on the line underlined. Why can we replace the underlined values with $(n/k)$ and $n$ respectively?

