Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a number, K, and it is random, so I should have K partitions of one array that they were find.
I have K-1 pivot, they are also random.
I must reorganize the array.

For example:

Array: 5 2 4 6 1 3

pivot: k-1=2 --> random Pivot 1: 4 and Pivot 2: 5

so I have 3 partitions.

I must use the Quicksort, and the Partition


C++
void KQUICKSORT(int* list,int k,int p, int r)
{
 int i=0;
    if(p<r)
	 {
		int *L = KPARTITION(list, k, p, r);
		
		 for(i=0;i<k;i++)
		 {
		   KQUICKSORT(list, k, L[i],L[i+1]-1);
		 }
	 }
   }


I have to implement this code, but I don't have K partition... help me
Posted

1 solution

Then go back to where you copied that code from, and look for it there.

We aren't here to do your homework! (And your tutor is probably aware of most of the "usual sources" so he'll spot it if it isn't really your own work anyway...)

I'd write it myself, if I was you - you will learn a lot better that way.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900