Question: Using the find word implementation, need process word: int find_word( struct linked_list *p_list, char *word ) { if(p_list == NULL || p_list->p_head == NULL){ return

Using the find word implementation, need process word:

int find_word( struct linked_list *p_list, char *word )

{

if(p_list == NULL || p_list->p_head == NULL){

return -1;

}

if(word==NULL || *word ==0 ){

return -1;

}

p_list->p_current = p_list->p_head;//assign current to head

//loop until current is null - this will compare the word passed vs the linked list word and return 1 if it is found

while(p_list->p_current != NULL){

if((strcmp(word, p_list->p_current->one_word.unique_word))==0){

return 1;

}

if(p_list->p_current->p_next != NULL){

p_list->p_current = p_list->p_current->p_next;

}

else{

break;

}

}

p_list->p_current = p_list->p_head;

while(p_list->p_current != NULL){

//checks to see if word is less than unique_word

if(strcmp(word, p_list->p_current->one_word.unique_word) < 0 ){

p_list->p_current = p_list->p_current->p_previous;

return 0;

}

if(p_list->p_current->p_next != NULL){

p_list->p_current= p_list->p_current->p_next;

}

else{

break;

}

}

return 0;

}

// First checks that p_list is not NULL. Returns 0 if p_list is a NULL pointer.

// Then checks that word pointer is not NULL and word is not any empty string.

// Returns 0 if either of the above tests on the passed word fails.

//

// Creates the list if starting a fresh list.

// Searches existing list for a match on the word. Increments word count

// if found. If not found adds the word in alphabetic order.

// Returns 1 if the word was added successfully.

// Returns 0 on failure.

// NOTE -- this function makes no assumption on upper or lower case. That is handled by read_file.

// For simplicity all words passed from the unit tests are all lower case only.

int process_word ( struct linked_list *p_list, char *word )

{

}

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!