make zip in the VSCode terminal to create a zip archive of your work. Log in to Gradescope at https://gradescope.com and upload it to the Sorted List assignment on Gradescope. You can resubmit as many times as you like before the deadline.
For this assignment, you will implement a sorted list. This data structure behaves like a normal list, except it maintains all of the values in sorted order (lowest to highest). You are free to implement this data structure using either a linked list or an array, but do not impose an upper limit on the number of elements that can appear in the list. The starter code includes a test program that creates a sorted list and then performs operations on that sorted list that it reads from the command line. Your task for this assignment is to implement each of the sorted list operations.
You will need to complete this assignment using the provided starter code, and upload your code to Gradescope. Follow these steps to set up your working copy of this assignment:
$ mkdir -p ~/csc213/assignments ~/csc213/exercises ~/csc213/labs
git command to check out a copy of the starter code for the assignment:
$ git clone /home/curtsinger/csc213/assignments/sorted-list ~/csc213/assignments/
code command to open the starter code with Visual Studio Code.
$ code ~/csc213/assignments/sorted-list
sorted-list directory open in the file browser. You may see a welcome message, which you can close. You can also close any prompts to upgrade to a new version of VSCode.make in the terminal to build the starter code, or just type ctrl+shift+b to run the default build task (which just runs make).We’ll use VSCode as the default editor for this class. You can use other editors if you prefer, but you’ll be missing out on some useful features. The VSCode projects I distribute will automatically format your C code, and will include some default settings that help with syntax highlighting, running build tasks, etc.
At this point you should read through the requirements for the assignment and review the provided code.
The assignment starter code has three source files:
main.csorted-list.hsorted_list_t struct in this file. You are welcome to add additional struct definitions here if you need them, but not global variables. You may not change the names or parameters of any functions declared in this file.sorted-list.cThe sorted list interface is similar to the stack example from class. Read the details below for information on what each function is meant to do.
void sorted_list_init(sorted_list_t* lst)lst pointer already points to this location when sorted_list_init is called, so you should not assign a new value to lst. Instead, just fill in any fields in lst required to represent an empty sorted list.void sorted_list_destroy(sorted_list_t* lst)lst pointer is managed by the caller, so do not free it here. If lst holds any pointers to allocated memory you are responsible for freeing those.void sorted_list_insert(sorted_list_t* lst, int value)size_t sorted_list_count(sorted_list_t* lst, int value)void sorted_list_print(sorted_list_t* lst)Here are a few example runs of the program that should help you test your implementation.
The order of values when printed should always be sorted, regardless of insertion order:
$ ./sorted-list
insert 5
insert 4
insert 1
print
1 4 5
insert 3
insert 2
print
1 2 3 4 5
Duplicate values should be preserved, and should appear in sorted order:
$ ./sorted-list
insert 9
insert 8
insert 9
insert 7
insert -3
insert 9
print
-3 7 8 9 9 9
The count command should print the number of times a value appears in the list:
$ ./sorted-list
insert 5
insert 4
insert 3
count 1
0
count 3
1
insert 3
count 3
2
print
3 3 4 5