Question: In C Programming: Using lab.c, lab.h, main.c files lab.h file: #include #include typedef struct nodestruct { int item; struct nodestruct *next; } Node; typedef struct
In C Programming:
Using lab.c, lab.h, main.c files
lab.h file:
#include
#include
typedef struct nodestruct {
int item;
struct nodestruct *next;
} Node;
typedef struct {
int size; // Number of items on users list
Node *head, *tail;
} List;
lab.c file will have two functions:
List* insertSortedNode(List*, int); This function creates a node containing the provided item, then adds it to the list pointed by the provided list pointer and stores the node based on the value of its key item in ascending order. Finally, it should return an updated list pointer. Note: index is zero based. void removeNode(List*, int); This function removes the node at the location provided by the index from the provided list pointer. Note: index is zero based. The function should be able to print out an error message if the index is beyond the size of the list. Also, make sure to free the memory of the removed node before you exit the function. main.c file: 1. Using the provided two ADTs, create a list. 2. Generate an array with 5 random integer numbers between 1 and 10. Print out the 'generated' numbers on the console separated by space. 3. Insert each of the generated numbers in the list using the insertSortedNode function. 4. Print the contents of the list on the console separated by space. 5. Remove the node at the 4th index of the list. Next, remove the node at the 1st index of the list. Finally remove the 11th index of the list. 6. Print the contents of the list on the console separated by space. Example output: mwc-070138:~ $ gcc main.c lab8.c -Wall -Werror mwc-070138:~ $ ./a.out Randomly 'generated' numbers: 1 3 7 2 10 Items on the list: 1 2 3 7 10 Index 11 does not exist. Unable to remove! Items on the list: 1 3 7 Have a Nice Day!!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
