Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void sequential_sort_2(int * V, int N, int * perm){
- int max, min, count, start=0, end=N-1;
- if(N<=0)
- return
- else if(N==1){
- perm[0] = 0;
- return;
- else {
- for(count=0, count<N, count++)
- perm[count] = count;
- while(start<end){
- for(min=start, max = start, count=start+1; count<end; count++){
- if(V[perm[count]] > V[perm[count+1]{
- if(V[perm[count]] > V[perm[max])
- max = count;
- if(V[perm[count+1]] < V[perm[min])
- min = count+1;
- }
- else{
- if(V[perm[count]] < V[perm[min]])
- min = count;
- if(V[perm[count+1] > V[per[max]]
- max = count+1;
- }
- }
- if(count == end){
- if(V[perm[count]] < V[perm[min]])
- min = count;
- }
- else
- if(V[perm[count]] > V[perm[max])
- max = count;
- swap(perm, min, start);
- swap)perm, max, end);
- start++;
- end--;
- }
- }
- }
- void swap(int * A, int i1, int i2){
- int tmp = A[i1];
- A[i1] = A[i2];
- A[i2] = tmp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement