Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yes, the algorithm suffers from a race condition. Time is not a synchronization primitive.


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)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: