pseudocode for iterative quickSort

Sadaiyappan

Golden Member
Nov 29, 2007
1,120
4
81
Hi! I'm supposed to write a quickSort that is non recursive. So I guess I will need to use loops and maybe a stack to do this. But I don't know where to start or how to do this. Can someone link to me a tutorial / guide (I can't find any good ones for C++ on google) or paste the pseudocode here for me???
 

Sadaiyappan

Golden Member
Nov 29, 2007
1,120
4
81
Also if I do use a stack I'm a little confused about how to implement the array. Do i put the array within the struct of the interface of the stack? Or do i create an array based stack? Or create a pointer based stack then create an array of objects? I am supposed to be able to sort 200,000 integers.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
A quick search of "iterative quicksort" yielded a bunch of results, many with code. I haven't looked at the implementation for quicksort in a couple of years so I can't directly help you, but before you will be able to write/understand an iterative implementation of it you should really have a firm understanding of how the sort works. If you really understand the algorithm, it's trivial to write it as either iterative or recursive.
 
Sep 29, 2004
18,656
68
91
Awesome, you want to do this for a living I am assuming, but you refuse to think for yourself. You will go no where with this kind of attitude.