Question: Here is the code to get started: Exercise 3 For this exercise, you wi ill implement string bubble sort by explicitly using pointers instead of

Here is the code to get started:

Exercise 3 For this exercise, you wi ill implement string bubble sort by explicitly using pointers instead of particular, you will implement the data structure as a 1-dimensional array of character pointers, char Strings[NUMJ. Thus, the index into the data structure yields a pointer, e.g., Stringslil gives you the i th pointer (of type char*). Stringsli]lil will, inturn, give you the j-th character of the i-th string This behavior is superficially identical to that of Exercises 1and 2, butthe implementation of the data structure is quite different. A benefit of this approach is that it allows the programmer to define the length of strings at runtime, instead of fixing it during coding Study the malloc0 and free0 functions, which are part of the Cstandard library, and are used to allocate rence for and free up, respectively, space in memory for a variable (see P&M Ch. 26; and the malloclfree in stdlib.h). The C function malloc0 is quite like the new operator in Java. Here is an example on how to use malloc0 to allocate 57 bytes of memory for a string (of max length 56plus one for the NULL terminating character char s s malloc(57); allocate 57 bytes for s puts("Enter a string:"); fgets(s, 57, stdin); print ("You typed In%sin", s); free(s) good practice to free up those 57 bytes so something else can use that space Observe that the following lines of code in Cand Java are equivalent char s malloc(57); in C charo s new char[57]; in Java Note: If you wanted to use a data type that is biggerthan a single byte, use the sizeof0 operator to determine the size in bytes float* s malloc(57'sizeof(float)); in C float[] s new float[571 in Java In C, there is a free0 function which frees up the memory allocated for a variable by malloc0.There is no such function in Java (the JVM does automatic garbage collection, and does not require the programmer to keep track of when a data structure is no longer needed). It is good practice to use free0 to free up the memory that was used for a variable right before that variable is about togo outof scope, or otherwise lost ifyou do not use free0, but it may start hogging to the program. Your program will still run corr memory unnecessarily, a frequent cause of "memory leaks" which often cause programs to bloat up during the course of the execution Using the starter file ex3.c, implement bubble sort of strings. Your code must strictly follow thes specifications Add "#include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
