Classic Quick Sort

View previous topic View next topic Go down

Classic Quick Sort

Post  viterbi on Thu Sep 08, 2011 10:45 am

1____void my_qsort(int* a, int N) {
2__________if (N <= 1) return;
3__________int l = 0;
4__________for (int i=1; i<N; i++)
5________________if (a[i] < a[0]) swap(a[++l], a[i]);
6__________swap(a[0], a[l]);
7__________my_qsort(a, l);
8__________my_qsort(a+l+1, N-l-1);
9____}

viterbi

Posts : 32
Join date : 2011-09-03

View user profile

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum