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

This still feels like ... cheating to me, if that's not too strong a word. If your algorithm for sorting a list involves generating a bigger list and then sorting that, then it's obvious that by recursion, you can make your sort function take forever.


A program that does not halt is not an algorithm. If you want to create a sorting algorithm, it has to halt, i.e. not run forever.


Not seeing that in either the definition and essentially all control algorithms, like say PID control, are meant to run "forever" (meaning longer than you can foresee in the code, they need an infinite loop)


You could consider that in PID control the actual algorithm is the single iteration, after which the output is sent out and a new set of inputs comes in, thus restarting the algorithm. In an endless iteration, you never give out any outputs


You can't run PID in a single iteration. The integration and differentiation parts would be 0 in any single iteration, and so it's quite PID control if you look at it that way.

The description of the algorithm doesn't make much sense in a single iteration either.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

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

Search: