Archived

This topic is now archived and is closed to further replies.

lil_nikk

Sorting for C++

Recommended Posts

Does any body know an iterative way to quick sort or to increase the stack flow size.. because right now i am using a recursive quick sort and for large arrays it crashes.. any help would be good

Share this post


Link to post
Share on other sites
You could run a loop and put the current frame being processed in a std::stack. That will move the control information from the stack proper into the heap, which may help your stack overflow problem.

Changing stack space allocated for a process is usually a function of a linker setting. How you change it depends on the linker. For MSVC it''s the /STACK flag.

A better solution is to change from a quick sort to an introspective sort. The standard library std::sort is usually implemented with introspective sorts in most modern standard library implementations.

Share this post


Link to post
Share on other sites