Question: using c only please !! Histograms In this assignment you use structs along with heap memory to create a histogram. Main Your main should do

using c only please !!

using c only please !! Histograms In this assignment you use structsalong with heap memory to create a histogram. Main Your main shoulddo the following. Please note that you might need to look at

Histograms In this assignment you use structs along with heap memory to create a histogram. Main Your main should do the following. Please note that you might need to look at the lower sections for more detail on each part. Call the readWords function. This function will read in a number of words from the user. You are not to create the array in the main, but instead readWords will create it for you. Thus, you will need to setup a pointer to handle the return of the array. I also suggest creating a struct to help you with the strings. You array of words will just be an array of this struct: typedef struct str char letters [38] string As an example of what this call should look like in the main is the following string words; int numWords words-readWords(&numWords); Next the main should call displayWords to display the words that were just read Next the main should cal makeHistogram to create a histogram from the words. Similar to above, you are not to create an array for your histogram in the main. The histogram will be created using heap memory within the makeHistogram function and returned to the main You will want to setup a struct to handle histograms. Your histogram will be an array of this struct. Note that the type of one of the fields is the previously defined struct for holding strings typedef struct hist string word; int freq: histogramEntry; Next the main should call displayHistogram to display the histogram that was just created. After displaying the histogram, the main should then call sortHistogram to sort the histogram into most frequent to least frequent. And lastly, main is to call displayHistogram again to display the sorted histogram. ReadWords This function should dynamically allocate an array with space for 20 strings on the heap using malloc It should then let the user enter strings, one by one, putting them into the slots of the array. When the user enters the word "done" the input will stop. The array should be returned as the return value. Note that if we created the array on the runtime stack we would not be able to return it this way Histograms In this assignment you use structs along with heap memory to create a histogram. Main Your main should do the following. Please note that you might need to look at the lower sections for more detail on each part. Call the readWords function. This function will read in a number of words from the user. You are not to create the array in the main, but instead readWords will create it for you. Thus, you will need to setup a pointer to handle the return of the array. I also suggest creating a struct to help you with the strings. You array of words will just be an array of this struct: typedef struct str char letters [38] string As an example of what this call should look like in the main is the following string words; int numWords words-readWords(&numWords); Next the main should call displayWords to display the words that were just read Next the main should cal makeHistogram to create a histogram from the words. Similar to above, you are not to create an array for your histogram in the main. The histogram will be created using heap memory within the makeHistogram function and returned to the main You will want to setup a struct to handle histograms. Your histogram will be an array of this struct. Note that the type of one of the fields is the previously defined struct for holding strings typedef struct hist string word; int freq: histogramEntry; Next the main should call displayHistogram to display the histogram that was just created. After displaying the histogram, the main should then call sortHistogram to sort the histogram into most frequent to least frequent. And lastly, main is to call displayHistogram again to display the sorted histogram. ReadWords This function should dynamically allocate an array with space for 20 strings on the heap using malloc It should then let the user enter strings, one by one, putting them into the slots of the array. When the user enters the word "done" the input will stop. The array should be returned as the return value. Note that if we created the array on the runtime stack we would not be able to return it this way

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!