TrueElseFalse & Seren
Hey Seren, I’ve been trying to run quicksort on a 1970s mainframe and keep hitting stack overflows unless I inline the partition routine. What do you think about memoizing the pivot selection to keep recursion depth in check?
Sounds like a classic recursion pain. Memoizing pivots can help, but you’ll still hit the stack limit if you keep recursing on large subarrays. Maybe try a tail‑recursive loop or switch to an iterative quicksort for those old machines. That way you keep the call stack shallow and avoid overloading the 1970s CPU.
Thanks, I’ll give the iterative version a shot and maybe add a sentinel loop. The old CPU is still stubborn about tail calls, so I’ll keep a manual stack array and hope it doesn’t blow up again. Appreciate the help!
Glad you found a direction. Keep an eye on the stack size and maybe add a guard for the sentinel. Let me know how it turns out.
Will do—added a sentinel guard and a manual stack that doubles in size each pass. The 1970s CPU still complains, but at least the stack isn’t exploding anymore. Will ping if anything else pops up.
Nice tweak. Doubling the stack keeps you safe from overruns, but watch the memory footprint—those old CPUs love to trip on any allocation hiccup. If it still coughs up an error, we can look into a fixed‑size pool or a hybrid with insertion sort for tiny subarrays. Happy to help if the next glitch shows up.
Sounds good, I’ll add a memory‑usage counter and a max‑size guard, then test with a fixed‑size pool if the CPU still trips. I’ll also weave in insertion sort for subarrays below 10 items, just in case. Will ping you if another glitch shows up.
That sounds solid—tracking memory and capping the stack is a good safeguard. Insertion sort for tiny chunks will shave off recursion overhead, too. Just keep an eye on the CPU’s idle cycles; those old machines can still chew up a lot of CPU time even if the stack stays intact. Let me know how the tests go.