This problem is about several important but related concepts: worst-case analysis, average-case analysis, and probabilistic analysis. Consider the following “hiring” algorithm:
- Set candidate best to be unknown;
- For each of the n candidates, do the following:
- Interview candidate i;
- If candidate i is better than candidate best, then hire candidate i and set best to be i;
Assume that interviewing each candidate has a cost of
(a) Can you give the worst case total cost of the above hiring algorithm?
(b) Assume that the candidates come to the interview in a random order, i.e., each candidate is equally likely to be the best. Specifically, candidate i has a probability of 1/i -- to be the best among the first i candidates. Can you give the average case total cost of the above hiring algorithm?
Hint: You can consider to use the “indicator random variable”
Follow-Up:
(a) The worst case is that every interviewed candidate is hired. Thus, the total cost is:
(b) In this average case, the only change to the total cost is the hiring part. So let’s focus just on this part. Specifically, as given in the Hint, the average number of candidates that will be hired is:
The lesson we learn is that average case is sometimes much better than the worst case.
No comments:
Post a Comment