Home > Back-end >  Look at me this quick sort trouble is there a problem?
Look at me this quick sort trouble is there a problem?

Time:09-24

Void tree (int * a, int left, int right)
{
If (left & gt;=right)/* if the left index greater than or equal to the right of index means has a set of completed, there is also a recursive loop ends conditions */
{
return;
}

Int I=left;
Int j=right;
Int k=a, [I].
While (I & lt; J & amp; & K & gt;=a [j])//I=j loop will end
{
J -;
}
If (I & lt; J)//here is to prevent an useless when I=j exchange
{
Swap (& amp; A [I], & amp; A [j]);
}

While (I & lt; J & amp; & K & lt;=a [I])
{
i++;
}
If (I & lt; J)
{
Swap (& amp; A [I], & amp; A [j]);
}


Tree (a, left, I - 1);//here I have=j, so for j can also left side recursive
Tree (a, I + 1, right);//right half recursive

}
  • Related