3 ms·
I don't care too much about efficiency. As a corollary to this, I often ask this same question as my opening question when interviewing candidates, and I find
by brown9-2 16y ago
I don't care too much about efficiency.
As a corollary to this, I often ask this same question as my opening question when interviewing candidates, and I find that asking what the big-O runtime of their proposed solution is is also a good indicator of talent/knowledge.
For example, if they answer with a recursive solution (return fib(n-1) + fib(n-2)) but are unable to figure out why it's performance will be worst than linear, then this is a red-flag on the topic of being able to analyze and compare different algorithms. If they answer with recursive and say "oh yeah the performance of this stinks but the code is elegant, I can re-write this to be linear" then it's a good sign.
- deleted 16y ago[deleted]
- wbhart 16y agoI recently wrote an interpreter in C for a made up language. As a test of its performance, I coded up a powmod function, powmod(a, e, n) = a^e mod n (where ^ is power not xor). The program contained the lines: if (n % 2 == 0) return (powmod(a, n/2, p) * powmod(a, n/2, p)) % p; else return (powmod(a, n/2, p) * powmod(a, (n+1)/2, p)) % p; The embarrassing thing is that even after having spent years writing mathematical code, it took me ages before I figured out it was not my interpreter, but this algorithm that was so ridiculously slow. Fortunately the interpreter is now really fast!