3 ms·
This is why it's a terrible idea to ask for some random algorithm runtime in an interview. It says absolutely nothing about programming or reasoning skill. I'd
by algorias 13y ago
This is why it's a terrible idea to ask for some random algorithm runtime in an interview. It says absolutely nothing about programming or reasoning skill.
I'd rather ask a candidate to explain their favorite data structure to me and derive it's big-O complexity right then and there. Being able to regurgitate the correct answer doesn't count for anything in my book.
- fatemayasmine 13y agoOften the followup question to what is the O notation of X is why? So if you are just going to memorize the cheat sheet then it won't get you very far. It is good to know what you should know about though.
- dllthomas 13y agoI was asked the O() of binary search. I said "log n". They asked "what base?" ... obviously they wanted 2, but O() doesn't work that way - changing base is a constant factor. Sometimes there's a tension between figuring out someone's understanding of the algorithm and someone's understanding of the notation (and math behind it). Of course, I gave them both answers...
- ot 13y ago> changing base is a constant factor. Only if the base is constant. For example B-trees have O(log_B n)-time operations, and you can't ignore the B because it is a parameter (hence non-constant).
- saraid216 13y agoMaybe they wanted both answers?
- crossroads091 13y agoWhat was the second answer?
- bastijn 13y ago2 and the "no need for base in big-O" makes 2 :).
- blt 13y agoFavorite data structure, that's a funny idea. Like asking a candidate to explain their favorite size of wrench.