Home > Back-end >  Quick sort to achieve process
Quick sort to achieve process

Time:09-22

Introduction to algorithms of 7.1 1 topic

I to the whole process of recursive or not too clear,,,

After the third line on the picture is not clear,,,

The code below
#include
#include

using namespace std;

A, int partition (int * int l, int r)
{
Int mid=a, [r].

Int I=l - 1;

For (int j=l; J & lt; r; J++)
{
If (a [j] {
i++;
Swap (a [I], a [j]);
}
}
Swap (a [I + 1], a [r]);

For (int k=0; K & lt; 12. K++)
{
cout }
Return the I + 1;


}

Void quick_sort (int * a, int l, int r)
{
Int mid;
If (l & lt; R)
{
Mid=partition (a, l, r);

cout Quick_sort (a, l, mid - 1);
Quick_sort (a, mid, r);
}

}

Int main ()
{
13,19,9,5,12,8,7,4,21,2,6,11 int a [12]={};
cout <"Tree:" & lt;
Quick_sort (a, 0, 10);

for(int i=0; i <12. I++)
{
cout
}

system("pause");
return 0;
}
  • Related