quicksort algorithm: does it look right?

I have an array of rational numbers and i am write a quicksort algorithm for it. However, the following one, doesn't have any impact on the array. Ideas?

publicvoid quickSort(int low,int high)

{

if (low>=high)return;

Rational pivot=array[high];

int left=low;

int right=high-1;

while (left<right)

{

while ((left><=right) && (array[left].compareTo(pivot)<0))

left++;

while ((left<=right) && (array[right].compareTo(pivot)>0))

right--;

if (left<right) swap(array[right],array[left]);

quickSort(low, left-1);

quickSort(left+1,high);

}

}

>

[1195 byte] By [uiga] at [2007-10-2 4:24:33]
# 1
I don't know what your swap method does, but I suspect it does absolutely nothing.
YAT_Archivista at 2007-7-15 23:52:22 > top of Java-index,Other Topics,Algorithms...
# 2

Do you mean that the problem is the swap method? Here it is:

//contained in class ArrayRational

private void swap(Rational a, Rational b)

{

Rational tmp= a.cloneRational();

a=b;

b=tmp;

}

.//contained in class Rational

public Rational cloneRational()

{

int enumer=this.getEnumerator();

int denom=this.getDenominator();

return new Rational(enumer, denom);

}

uiga at 2007-7-15 23:52:22 > top of Java-index,Other Topics,Algorithms...
# 3
> Do you mean that the problem is the swap method?Yes, and I was right. Do you think Java uses pass-by-name?! Try making swap take an Object[] and two indices.
YAT_Archivista at 2007-7-15 23:52:22 > top of Java-index,Other Topics,Algorithms...