Corning Community College
CSCS2320 Data Structures
Take your C malloc()'d array implementation of Vircon32 snake, and convert it to use a singly-linked list.
You will want to go here to edit and fill in the various sections of the document:
Reference: https://www.geeksforgeeks.org/introduction-to-linked-list-data-structure-and-algorithm-tutorial/
A linked list is a data structure that allows for a list of elements that can dynamically increase and decrease in size.
Usually, in C, an array can only have a static size once it is declared, and once it is filled, it can no longer get any more space or elements added to it.
Since a linked list is a series of “nodes”, or structs that point to each other, then new elements can easily be added: as long as there is enough memory to be allocated to a new struct, the last struct in a linked list can be made to point to this new struct.
The same also applies for removing elements. Once an element has been removed from a linked list, the memory can be freed so it can be used elsewhere, if needed.
Since this project deals with linked lists and dynamically adding and removing elements from a list, malloc will still need to be used to allocate memory.
Generally, malloc will need to be used to add a new element to a linked list.
The pseudocode will look like so:
functionForAddingElement(args) { struct* newStruct = (struct*)malloc(sizeof(struct)); // Place Data into New Struct // Loop through Linked List to the End // Place New Struct at End of List }
Reference: https://www.geeksforgeeks.org/insertion-in-linked-list/
To be successful in this project, the following criteria (or their equivalent) must be met:
Let's say you have completed work on the project, and are ready to submit, you would do the following:
lab46:~/src/SEMESTER/DESIG/PROJECT$ submit DESIG PROJECT file1 file2 file3 ... fileN
You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.
I'll be evaluating the project based on the following criteria:
130:mpg2:final tally of results (130/130) *:mpg2:clean compile, no warnings or errors [26/26] *:mpg2:implementation of node with next pointer [26/26] *:mpg2:implementation of singly linked list of nodes [26/26] *:mpg2:utilization of singly linked list of nodes [26/26] *:mpg2:source and resources tracked in semester repository [26/26]