Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Array::BitSort(int *a, int n, int start, int end, int cmpByte)
- {
- int i = start;
- int j = end;
- if (i < j)
- {
- int mask = 1 << cmpByte;
- while (i <= j)
- {
- for (; i <= j && !(a[i] & mask); i++);
- for (; i <= j && (a[j] & mask); j--);
- if (i < j)
- {
- Swap(&a[i], &a[j]);
- i++;
- j--;
- }
- }
- if (start < j)
- {
- BitSort(a, n, start, j, cmpByte - 1);
- }
- if (i < end)
- {
- BitSort(a, n, i, end, cmpByte - 1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement