just need the answers to the following 3


Just need the answers to the following 3 questions. "NO NEED to write a program compile or run it, do not need it. Just need the answers for the following questions.

Example question?

Write a hello world program that prints "hello world" twice:

Answer should be in this format:

void_helloworld()
case=1
for ((i=0; i<=case, i++))
{
do
print("hello world");
done
}


Question 1 Floating Point Radix Sort:

Write a C program to sort 32-bit floating point numbers using 8-bit (256 bins) radix sort. Use the variables listed bellow. Floating point numbers require a correctional step after the main loop is completed. Assume lst is initialized with n floating point numbers.

#define N 1048576
#define BIN 256
#define MAXBIT 32
#define LST 1
#define BUF 0
int n, group=8, bin = 256;
int flag; /*to show which one holds numbers: lst or buf*/
float lst [N], buf[N];
int count[BIN], map[BIN], tmap[BIN];

int main (int argc, char ** argv)
{
int i;
flag = LST;
initialize(); /* initilize lst with n random floats */
for( i =0; i < MAXBIT; i=i + group) radix_sort(i); /*move lst to buf to lst depending on the iteration number */
correct(); /*sorted numbers must be in lst */
}
void radix_sort(int idx)
{
int i,j,k,mask; /*initilize mask for lifting the 8 least significant bits. */
int *src_p, *dst_p; /* cast lst and but to int pointers to treat lst/buf as int''s */
/*set src_p and dst_p*/

/*count */

/*map*/

/*move*/
}

void correct()
{
}

__________________________________________________________________

Question 2 -- Splitting a String:

Write a C function that splits a string line separated by commas and stores the values in an array of string fields. The number of commas is unknown and your function must be able to handle any number of commas in the string. Use the following built -in functions: strtok(line, delim); strtok(NULL, delim); malloc(strlen(token)); strcpy(fields[i], token);

/* at the end of this function, fields will have n string store */

void split_line(char ** fields, char *line)
{
int i=0;
char *token, *delim;
........
}

_________________________________________________________

Question 3 Building an array of link list:

Assuming you got split_line() working, complete build_lsts() that builds a list of clips. When building a list, prepend a clip to the list, in other words, add a clip to the front, no the end.

struct clip { int number, int views; char * user; char * id; char * tittle; char * time; struct clip* next;};
struct clip * hourly[MAX_CLIPS];
void build_lsts(char *prefix)
{
FILE *fp; char * cmd, * filename; int i;
for ( i=0; i hourly [i]= NULL;
sprintf(cmd, "ls % s*", prefix); fp = popen(cmd, "r"); i=0;
while (fscanf(fp, "%s", filename) ==1) hourly [i++] = build_a_lst(filename); fclose(fp);
}

/*four steps: open the file, read a line at a time, call split_line() to split the line and store in fields, and call prepend() to insert the clip to the front*/


struct clip *build _a_lst(char *fn)
{
........................

return hp:
}

/*three steps: malloc a clip, set values to clip but set views only! add the clip to the front */

struct clip *prepend (struct clip * hp, char **five)
{
.....

return hp;
}

Thanks.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: just need the answers to the following 3
Reference No:- TGS0275086

Expected delivery within 24 Hours