Answer To: Microsoft Word - radixsort.docx Objectives 1. To learn how to sort integers using radix sort. 2. To...
Swapnil answered on Jun 28 2021
87129/1.c
#include
int main(int argc, char* argv[])
{
char const* const fName = argv[1];
FILE* file = fopen(fName, "r");
char l[256];
uint32_t pArray[256];
int cmpr(const void *a, const void *b)
{
const unsigned long long *x = a, *y = b;
if(*x > *y)
return 1;
else
return(*x < *y) ? -1: 0;
}
int lCntr = 0;
while(fgets(l, sizeof(l), file))
{
uint32_t t = (uint32_t) l;
pArray[lCntr]=t;
lCntr++;
printf("Original: %s, Unsigned Int: %u\n", l,t);
}
qsort(&pArray[0],lCntr+1,sizeof(uint32_t*),cmpr);
int i;
for(i=0;i {
printf("%u\n",pArray[i]);
}
return 0;
}
87129/2.c
#include
int main()
{
int ar, br, cr;
float exchng, desc[100];
printf("Enter How many elements to sort : \n");
scanf("%d", &ar);
printf("Enter %d Real numbers \n", ar);
for (br=1; br<=ar; ++br)
scanf("%f", &desc[br]);
for (br=1; br<=ar-1; ++br)
{
for (cr=br+1; cr<=ar; ++cr)
{
if (desc[br] > desc[cr])
{
exchng = desc[br];
desc[br] = desc[cr];
desc[cr] = exchng;
}
}
}
printf("The Sorted list of real numbers in ascending order : \n");
for (br=1; br<=ar; ++br)
printf("%f\n", desc[br]);
return 0;
}
87129/3.py
class Parseeror(Exception): pass
# ==============================================================
# FRONT END PARSER
# ==============================================================
i = 0
er = None
def exp():
global i, er
v = t()
while True:
if w[i] == '+':
i += 1
v = binary_op('+', v, t())
elif w[i] == '-':
i += 1
v = binary_op('-', v, t())
else:
break
return v
def t():
global i, er
v = f()
while True:
if w[i] == '*':
i += 1
v = binary_op('*', v,...