This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Implementation void radix(unsigned int *a, int n) { //allocate scratch memory unsigned int *a2 = new unsigned int[n]; assert( a2 != NULL ); int M = 8 * sizeof( unsigned int ); for (int j = 0; j < M; j++) { int J = 0; for (int k = 0; k < n; k++) { if (a[k] & (1<<i) == 0) { a2[J] = a[k]; J++; } } //copy keys with 1s to a2 for (int k = 0; k < n; k++) { if (a[k] & (1<<i) != 0) { a2[j] = a[k]; } } //copy a2 to a memcpy(a, a2, n * sizeof(unsigned int)); } } M = O(log n)...
View
Full
Document
This note was uploaded on 02/02/2012 for the course CS 251 taught by Professor Staff during the Fall '08 term at Purdue UniversityWest Lafayette.
 Fall '08
 Staff
 Data Structures, Sort

Click to edit the document details