P
pinkfog
Hello,all
I m just a newbie to c,and now i m learning quick sorting,i dont very
undertand this algorrithm,can someone kind to explain it to me?
the code:
<quote>
void quick_sort(int a[] ,int low ,int high)
{
int i =low;
int j =high ;
int t= a;
while(i<j)
{
while(i<j&&a[j]>t)
j--;
a =a[j];
while(i<j&&a<=t)
i++;
a[j] =a;
a =t;
quick_sort(a,low,i-1);
quick_sort(a,i+1,high);
}
}
<quote>
why does the code do this, esp. after the second while-statement the
assignment"a=a[j]",and the third while-statement the assignment
"a[j] =a"?
I m very confused.Any reply is appreciated.Thanks.
-------------------------------pinkfog---------------------------------------------
I m just a newbie to c,and now i m learning quick sorting,i dont very
undertand this algorrithm,can someone kind to explain it to me?
the code:
<quote>
void quick_sort(int a[] ,int low ,int high)
{
int i =low;
int j =high ;
int t= a;
while(i<j)
{
while(i<j&&a[j]>t)
j--;
a =a[j];
while(i<j&&a<=t)
i++;
a[j] =a;
a =t;
quick_sort(a,low,i-1);
quick_sort(a,i+1,high);
}
}
<quote>
why does the code do this, esp. after the second while-statement the
assignment"a=a[j]",and the third while-statement the assignment
"a[j] =a"?
I m very confused.Any reply is appreciated.Thanks.
-------------------------------pinkfog---------------------------------------------