From ch09a-single-linklist.ppt, copy/paste programs into list.h, list.c,and driver.c in a directory, say recit08, and create Makefile to compile them.

Then extend list library with the following additional functions

void FreeList(listADT a);
void list_print_values(listADT a, char *name); double list_average(listADT a);
void list_delete_by_value(listADT a, listElementT x) ;
// this function only deletes the first element it finds. listADT list_n_copy(listADT a, int n);
// make a new list, copy the first n values from list a

Finally, modify driver.c program such that it creates two lists, say X and Y. Then do the followings:

1.In a loop, get 6 integer values from the user and insert them into X and Y, in a sorted and unsorted manner, respectively by calling the appropriate functions.

2.Print both lists X and Y.

3.Find and print the averages of values in both lists by calling list_average( )

4.Ask user to enter a value to remove from both list and call list_delete_by_value( ) to remove the given value from both lists X and Y.

5.Print both lists X and Y

6.Find and print the averages of values in both lists by calling list_average( )

7.Call Z = list_n_copy(X, 3); to create a new list Z which contains the copies of the first three values in list X.

8.Print list Z

9.Find and print the average of values in list Z by calling list_average( )

10.Free all the lists

As always, make sure you release (free) the dynamically allocated memories if you allocate any memory in your programs. So, before submitting your program, run it with valgrind to see if there is any memory leakage

Also if you need to debug your program, compile your programs with g option and then run it with gdb and/or ddd.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.