Hacker News new | ask | show | jobs
by colanderman 1071 days ago
Yes, the algorithm suffers from a race condition. Time is not a synchronization primitive.
1 comments

Yup. If we are being pedantic, and I am sure the author of this loves being pedantic, any number of factors could cause this algorithm to be incorrect. Put it in a slow enough cpu for instance, and it will output the wrong answer.

And correctness is the single most important part of an algorithm. We can do any problem in constant time if we don't mind our answers are not correct.

return(4)