Question: You will implement a linked list data structure in this assignment. The linked list will consist of a head pointer and a tail pointer. The

You will implement a linked list data structure in this assignment. The linked list will consist of a head pointer and a tail pointer. The head pointer will point to a Node struct, which will hold a data void pointer as well as a pointer to the next node in the list. The tail pointer will point to the final node in the linked list. The next pointer on the tail will point to NULL. head ---> void* void* void* ---> NULL tail The List and Node structs are declared in linkedlist.h, along with a number of functions you will need to implement. // Initialize an empty list. The head and tail pointers should point to NULL. void initList(List* list_pointer); // Create Node struct containing a void pointer to an item, return pointer to the newly created Node struct Node* createNode(void* item); // Insert new Node at the end of the list, containing a void pointer to item. The next pointer on this Node // points to NULL. On success return 0. On failure, return 1. int insertAtTail(List* list_pointer, void* item); // Insert a Node at the head of the list, containing a void pointer to item. The next pointer on the // newly created node points to the previous head of hte list. On success return 0. On failure, return 1. int insertAtHead (List* list_pointer, void* item); // Insert a Node at the specified index, containing a void pointer to item. If the index is greater than // the length of the list, the program should crash. On success return 0. On failure, return 1. int insertAtIndex (List* list_pointer, int index, void* item); // Remove Node from the end of list and return the void pointer it contains. The preceeding Node should // point to NULL after this operation. On failure return a NULL pointer. void* removeTail(List* list_pointer); // Remove Node from start of list and return return the void pointer it contains. The following Node should // be the new head of the list. On failure return a NULL pointer. void removeHead (List* list_pointer); // Insert Node item at a specified index and return return the void pointer it contains. The Node at the specifi // index before this function is called should be the next Node following the newly inserted Node. // On failure return a NULL pointer. void* removeAtIndex(List* list_pointer, int index); // Return the pointer stored in the Node at the specified index. On failure return a NULL pointer. void* itemAtIndex (List* list_pointer, int index)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
