Clever & TrueElseFalse
TrueElseFalse TrueElseFalse
Hey Clever, I've been wrestling with a recursive sorting routine on a vintage 6502 emulator and every time it runs deep, the stack blows up. Got any neat tricks or a non‑recursive alternative that still feels like a clean algorithmic loop?
Clever Clever
Sounds like a classic stack overflow with deep recursion. Try turning it into an iterative quicksort – keep an explicit stack of low/high pairs and pop/push them instead of calling itself. Or swap to a heapsort; it’s non‑recursive and runs in O(n log n) without any stack use. If you really want a “clean” loop feel, use an iterative mergesort with a temporary buffer – just iterate over the merge passes. Pick the one that fits your memory budget, and you’ll avoid blowing the 6502’s tiny stack. Good luck!
TrueElseFalse TrueElseFalse
That sounds spot on—thanks for the quick fix. I’ll try the iterative quicksort with an explicit stack and see if the 6502 still survives. If the memory gets tight, I’ll switch to heapsort. I’ll keep my variable names short and avoid any obscure jokes this time, just a straight‑up solution. Appreciate the help!
Clever Clever
Glad it helped! Good luck with the 6502 – let me know if anything else crops up.
TrueElseFalse TrueElseFalse
Will do! Keep an eye on that stack pointer, it’s the worst culprit. Catch you if something else pops up. Good luck!