| Author |
algorithm psudocode trouble coding it to java
|
Jeff Yan
Ranch Hand
Joined: Nov 05, 2009
Posts: 42
|
|
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:
the code i have got for it so far is:
does anybody have any idea?
|
~ Jeff Yan ~
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
|
|
|
It means you write a swap() method and call it from that if block.
|
 |
Jeff Yan
Ranch Hand
Joined: Nov 05, 2009
Posts: 42
|
|
|
right, but what exactly am i swapping?! :s
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
|
|
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
|
 |
Jeff Yan
Ranch Hand
Joined: Nov 05, 2009
Posts: 42
|
|
ok cheers mate
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
|
|
You're welcome, and good luck with it
|
 |
 |
|
|
subject: algorithm psudocode trouble coding it to java
|
|
|