Question: Here is the code done in C Problem 5.c code /*** PROBLEM 5.3: Insertion Sort ***/ /* Determines if the word is already in the

 Here is the code done in C Problem 5.c code /***

Here is the code done in C

Problem 5.c code

/*** PROBLEM 5.3: Insertion Sort ***/

/* Determines if the word is already in the list. If it is, then the number of * occurrences for that word is incremented. If it isn't, then a new node is * created for the word and inserted into the list at the correct alphabetic * location. Returns a pointer to the head of the list, which is either the * original head or a node containing the word (if the word occurs before the * original head's word or if the original head is NULL). */ struct node *insert_word(struct node *head, const char *word) { /* WRITE THIS FUNCTION */ return NULL; }

/* Gets the name of the book file from the user and reads the file line-by-line. * Under the assumption that there is exactly one word per line and that all * punctuation has been removed, this function builds a doubly-linked list * of the words in alphabetical order, keeping track (as part of a node's * payload) how many times each word occurs in the file. */ struct node *build_list() { const char *filename = get_input("Enter the name of the book file"); /* WRITE THE REST OF THIS FUNCTION */ return NULL; }

5.3 Insertion Sort The insertion sort algorithm reads an input and then traverse erses a sorted list to find the proper location in the sorted list for the input. The input is then inserted into the list at that location. For this problem, the user will be prompted to enter the name of a book, which will be the filename of a file that contains all of the book's words. All punctuation has already been removed from the files, and each line in the file contains exactly one word. In problem5.c, write the code to read the file one line at a time. For each word, convert it to lowercase, and then traverse the list to find the appropriate place for the word. (Note that there will not be a list to traverse when your code reads the first word!) If the word is not in the list then create a node for that word and insert it into the list at the correct location. If there is already a node containing that word, then increment that node's variable that tracks the number of occurrences. If your program requires more than a few seconds to build the list, there is a bug in your code

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!