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: 38818

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