3 ms·
Btw, depending on application, sometimes you don't want early termination. Eg for some cryptographic applications you don't want to leak information about what
by eru 7y ago
Btw, depending on application, sometimes you don't want early termination.
Eg for some cryptographic applications you don't want to leak information about what data you are working on in the runtime of your algorithm.
Another (more far-fetched?) scenario might come up with either branch prediction and CPU pipelining, or your compiler's optimizer recognising the simple loop but not the one that has early abort.
- pacaro 7y agoYeah, creating constant time code is its own challenge, if a candidate were to bring that up it could take the interview down a very different path
- a1369209993 7y ago> either branch prediction and CPU pipelining Not that far-fetched; the non-early-aborting loop can be branch-predicted perfectly by a smart enough CPU.