hi can you write (Floating Point Radix sort) I have given formet of unsinged redix sort(as refrences) so may be you can use that formet just just what has to chnage in Floating Point Radix sort need. this is my question of ss

icon
Related questions
Question

hi can you write (Floating Point Radix sort) I have given formet of unsinged redix sort(as refrences) so may be you can use that formet just just what has to chnage in Floating Point Radix sort need. this is my question of ss 

Problem 17 (Unsigned integer radix sort - ): Write a C program for sorting 32-bit unsigned integers
using radix sort with a group of 4 bits. Use the variables listed below. Assume 1st is initialized with n numbers.
#define N 1048576
#define BIN 256
#define MAXBIT 32
#define LST 1
#define BUF @
int n, group, bin;
int flag; /* to show which one holds numbers: 1st or buf */
int 1st [N], buf[N];
int count [BIN], map[BIN], tmap [BIN];
int main(int argc, char **argv) {
int i;
flag = LST;
initialize(); /* initialize 1st with n random floats */
for (i =0; i < MAXBIT; i = i + group)
radix_sort(i); /* move 1st to buf or buf to 1st depending on the iteration number */
correct(); /* sorted numbers must be in 1st */
}
void radix_sort(int idx) {
int i, j, k, mask; /* initialize mask for lifting the 4 least significant bits. */
int src_p, dst_p; /* cast 1st and buf to int pointers to treat 1st/buf as int's */
/* set src_p and dst_p */
if (flag
LST) {
src_p= 1st;
}
dst_p = buf;
} else {
src_p buf;
dst_p = 1st;
}
// Initialize mask for lifting the least significant bits
mask = (1 << 4) - 1;
for (i = 0; i < BIN; i++) {
count[i] = 0;
map[i] = 0;
}
for (i = 0; i<n; i++) {
}
map [0] = 0;
for (i = 1; i < BIN; i++) {
}
for (i = 0; i<n; i++) {
dst_p[map[(src_p[i] >> idx) & mask]++] = src_p[i];
}
flag (flag == LST)? BUF: LST;
count[(src_p[1] >>´idx) & mask]++;
map[i] = map[i-1]+ count[i-1];
=
}
void correct() {
unsigned int i;
for (i = 0; i < N;i++) {
if ((i+n) < N)
else
buf[i] = 1st[i + (N − n)];
buf[i] = 1st[i-n];
}
for (i = 0; i<n; i++) {
1st[i] = buf[i];
}
Transcribed Image Text:Problem 17 (Unsigned integer radix sort - ): Write a C program for sorting 32-bit unsigned integers using radix sort with a group of 4 bits. Use the variables listed below. Assume 1st is initialized with n numbers. #define N 1048576 #define BIN 256 #define MAXBIT 32 #define LST 1 #define BUF @ int n, group, bin; int flag; /* to show which one holds numbers: 1st or buf */ int 1st [N], buf[N]; int count [BIN], map[BIN], tmap [BIN]; int main(int argc, char **argv) { int i; flag = LST; initialize(); /* initialize 1st with n random floats */ for (i =0; i < MAXBIT; i = i + group) radix_sort(i); /* move 1st to buf or buf to 1st depending on the iteration number */ correct(); /* sorted numbers must be in 1st */ } void radix_sort(int idx) { int i, j, k, mask; /* initialize mask for lifting the 4 least significant bits. */ int src_p, dst_p; /* cast 1st and buf to int pointers to treat 1st/buf as int's */ /* set src_p and dst_p */ if (flag LST) { src_p= 1st; } dst_p = buf; } else { src_p buf; dst_p = 1st; } // Initialize mask for lifting the least significant bits mask = (1 << 4) - 1; for (i = 0; i < BIN; i++) { count[i] = 0; map[i] = 0; } for (i = 0; i<n; i++) { } map [0] = 0; for (i = 1; i < BIN; i++) { } for (i = 0; i<n; i++) { dst_p[map[(src_p[i] >> idx) & mask]++] = src_p[i]; } flag (flag == LST)? BUF: LST; count[(src_p[1] >>´idx) & mask]++; map[i] = map[i-1]+ count[i-1]; = } void correct() { unsigned int i; for (i = 0; i < N;i++) { if ((i+n) < N) else buf[i] = 1st[i + (N − n)]; buf[i] = 1st[i-n]; } for (i = 0; i<n; i++) { 1st[i] = buf[i]; }
(Floating Point Radix sort - ): Write a C program for sorting 32-bit floating point numbers using 8-bit (256 bins) radix sort. Use the variables listed below. Floating point numbers require
a correctional step after the main loop is completed. Assume 1st is initialized with n floating point numbers.
int main(int argc, char **argv) {
int i;
flag = LST;
initialize(); /* initialize 1st with n random floats */
for (i=0; i<MAXBIT;i=i+group) radix_sort(i); /* move 1st to buf or buf to 1st depending on the iteration number */
correct(); /* sorted numbers must be in 1st */
}
void radix_sort(int idx) {
int i,j,k,mask; /* initialize mask for lifting the 8 least significant bits. */
int *src_p,*dst_p; /* cast 1st and buf to int pointers to treat 1st/buf as int's */
1/* set src_p and dst_p*/
2/* count */
3/* map */
4/* move */
}
5.void correct() {
}
Ln 1, Col 30
100%
Windows (CRLF)
UTF-8
Transcribed Image Text:(Floating Point Radix sort - ): Write a C program for sorting 32-bit floating point numbers using 8-bit (256 bins) radix sort. Use the variables listed below. Floating point numbers require a correctional step after the main loop is completed. Assume 1st is initialized with n floating point numbers. int main(int argc, char **argv) { int i; flag = LST; initialize(); /* initialize 1st with n random floats */ for (i=0; i<MAXBIT;i=i+group) radix_sort(i); /* move 1st to buf or buf to 1st depending on the iteration number */ correct(); /* sorted numbers must be in 1st */ } void radix_sort(int idx) { int i,j,k,mask; /* initialize mask for lifting the 8 least significant bits. */ int *src_p,*dst_p; /* cast 1st and buf to int pointers to treat 1st/buf as int's */ 1/* set src_p and dst_p*/ 2/* count */ 3/* map */ 4/* move */ } 5.void correct() { } Ln 1, Col 30 100% Windows (CRLF) UTF-8
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer