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

When people say they expect someone to implement cycle detection, they usually mean Floyd's algorithm.

Not necessarily. Sometimes the dataset only has on the order of 10k nodes, and you just want to warn users if they create a cycle, or keep particular routines from going into an infinite loop.

If you come up with something else (like tagging nodes), you get a strike for inefficiency.

A few days ago, I implemented cycle detection in an event notification system where the graph size is relatively small in just 4 lines of code, which should be immediately understandable by any competent programmer. That you should mandate Floyd's algorithm in all cases gives you a strike for pedantic design without regard to cost/benefit.



I'm not sure what are you trying to argue. I never ask obscure CS trivia, you misread my post entirely.




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

Search: