ECE 26400: Programming Assignment VI Rayane G. Chatrieux Summer 2020 Introduction One of the things linked lists are good at is arbitrary insertions, meaning insertion of a link at any point in the...

Can i get this for $100?


ECE 26400: Programming Assignment VI Rayane G. Chatrieux Summer 2020 Introduction One of the things linked lists are good at is arbitrary insertions, meaning insertion of a link at any point in the linked list. This is true because the computer needs only to read/write the previous and the next link in the chain. This property allows us to implement lists that can be efficiently maintained as sorted. In this programming assignment, you’ll be implementing such a list. Setup Run the setup script at /home/nano01/a/rchatrie/teachings/ece264/assignments/pa06/setup. This script will copy over several files, as with the previous assignment. Problem Description Your task in this assignment is to implement a doubly linked list of grades. The grade structure is defined in grade.h as follows. 1 struct grade { 2 int grade; // Grade out of 20 3 struct grade *prev; // Pointer to previous grade in grade list 4 struct grade *next; // Pointer to next grade in grade list 5 }; Each grade structure has an int grade attribute that represents a grade out of 20, a struct grade *prev attribute that stores the pointer to the previous element in the linked list, and a struct grade *next at- tribute that stores the pointer to the next element in the linked list. In order to implement the linked list, you’ll have to write the 9 functions declared in grade.h following the structure definition. Each of these functions performs a specific operation on a grade linked list. grade alloc(): This function allocates and initializes a grade structure on the heap. It returns a pointer to the allocated structure. It does not print anything to stdout. Error messages should be printed to stderr. grade free(): This function frees the memory associated with a grade structure from heap memory. It does not return anything. It does not print anything to stdout. Error messages should be printed to stderr. grade insert(): This function should insert a grade structure into a grade list such that the list’s de- scending order starting from the list head is maintained. You can assume that the linked list provided to this function is sorted in descending order. This function should return the updated list’s head. It does not return anything. It does not print anything to stdout. Error messages should be printed to stderr. grade search(): This function should search for a grade structure in the grade linked list based on a given grade out of 20. It should return a pointer to the desired grade structure (do not remove said structure from the list!). If the desired grade is not in the linked list, the function should return NULL. This function should return a pointer to the updated list head. It does not return anything. It does not print anything to stdout. Error messages should be printed to stderr. grade remove first(): This function should remove the first grade structure, the one pointed to by the list head, from the grade list. It should return the updated list’s head. It does not print anything to stdout. Error messages should be printed to stderr. grade remove last(): This function should remove the last grade structure from the grade list. It should return the updated list’s head. It does not print anything to stdout. Error messages should be printed to stderr. grade remove() (Extra credit): This function should remove all grades from the grade list that are strictly less than a given grade out of 20, passed as parameter to the function. It should return the updated list’s head. It does not print anything to stdout. Error messages should be printed to stderr. grades print ascending(): This function should print to stdout the grades in the grade list in ascending order. This function should not return anything. For example, if the grade list contains the grades 17, 10, 5, the function should print the following. 5, 10, 17 grades print descending(): This function should print to stdout the grades in the grade list in descend- ing order. This function should not return anything. For example, if the grade list contains the grades 17, 10, 5, the function should print the following. 17, 10, 5 Requirements Below are listed the requirements for this assignment. (1) You must write your code in C11 and you may only use the standard library functions that come with that standard (once again, if the function is in the manual, you can go ahead and use it). (2) You must submit a makefile that has a working recipe to compile and link your code. We will be using that makefile recipe to compile your code. (3) Any code that is already written by me must remain. You may only add code to the source files. However, you are free to add code anywhere (e.g. include additional header files, write more functions, etc.). (4) Do not modify struct grade defined in grade.h. (5) You must implement each of the functions defined above (grade remove() is only for extra credit, and you do not have to implement it). Each function will be graded separately wherever possible. Inputs In order to thoroughly test your doubly linked list implementation, you’ll need to write additional code around it. Indeed, you’ll need to write your own input file parser (declared in parse.h for you) and main function. Note that you will not be graded on any code besides the required functions discussed above! You have the freedom to implement your parser and your main function however you want to test your implementation. To simplify the task, the input file format proposed is very simple. The provided input file grades/2020.txt simply lists grade scores out of 20 line by line. You can choose any other format. Once again, all that matter for your grade is your linked list implementation. I am giving complete freedom in terms of how you want to test it. Compiling and Linking A makefile that you have to complete has been provided for you. The same instructions and suggestions I provided for last assignment apply for this one as well. Testing As stated above, to test your code, you’ll have to write test code in parse.c and main.c, at least. Then, you’ll need to write some input files (one is provided for you). You should test each function separately, which is what we will do to grade your work. As I mentioned in lecture, in any situation you find yourself programming in C in a job or for research, you need to write your own test code, and come up with your own test cases. This assignment has been made into a simple application of lecture concepts regarding linked lists so that you can spend some time getting to this testing freedom. Submission Your submission on Brightspace should consist of a single compressed archive folder containing all the source and header files as well as your Makefile. To create the archive, go to the folder that contains these files as type the following command. tar -czvf pa06.tar.gz This will create the archive named pa06.tar.gz that you can submit. Remember that we will use your makefile to compile and link your code. Do not forget to include the makefile in the archive you submit!
Jul 25, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here