One lookup, two answers
transcript
Your service keeps a list of a thousand ids. It scans from the front, and stops at the first match. Your team lead asks what one lookup costs. The honest answer is that it depends on the input.
Look up the very first id in the list. The scan makes one comparison, and it stops there. The other nine hundred ninety nine ids are never read. That is the best case, and it is only luck.
Now look up the last id in the list. Or look up an id that is not registered at all. Either way the scan reads all one thousand ids. That is the worst case, and it holds for every input.
Say every registered id is equally likely to be asked for. The counts run from one up to one thousand. Their average is five hundred and a half comparisons. Change the mix of requests, and the average changes with it.
Plan a promise on the worst case. Never plan on the best case, because it is only luck. Quote an average only together with the mix it assumes.
Name the input, then name the case. Full breakdown in the lecture.