This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.

hey all, im struggling abit with some psudocode that i have to convert to java. basically im writing a quicksort algorithm which i have been supplied the psudocode for. but im having trouble analysing the psudocode on what part of it.

the bit i am stuck on is it says:

swap(A,pL,pR)

with A being the array of integers i have, and pL and pR being integers of some sort. here is the full psudocode; it is to partition the array before sorting:

It means you write a swap() method and call it from that if block.

Jeff Yan
Ranch Hand

Joined: Nov 05, 2009
Posts: 42

posted

0

right, but what exactly am i swapping?! :s

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38519

23

posted

0

Not sure. Try the elements of the array pointed to by the numbers "left" and "right"

Or Google for quicksort and you are bound to find the algorithm explained. I can't remember the details of quicksort. If you do Google you will find (inter alia) this, this and this. You will probably understand the first two of those links