Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C Programm Task Lists are by far the most commonly used dynamic data structure. For this task you should use a doubly linked and sortable
C Programm Task Lists are by far the most commonly used dynamic data structure. For this task you should use a doubly linked and sortable list (ascending by implement value). You can use different circumstances for the implementation of this task: The list contains only a single unsigned int value per node Because of the double concatenation, the individual nodes in the list have not only the value but also pointers to the respective next and previous node Implement at least some of the following operations o void insert(node_t** head, unsigned int index, unsigned int value); // insert in the list at the position index o void prepend(node_t** head, unsigned int value); // Paste to first place in the list o void append(node_t** head, unsigned int value); // insert at last position of the list o void sort(node_t** head); // Sort the list in ascending order related to the value Value o void insertSorted(node_t** head, unsigned int value); // sorted Insert in the list o unsigned int length(node_t* head); // Returns the current length of the list o unsigned int get(node_t* head, unsigned int index); // Returns the value in the index Index o unsigned int delete(node_t** head, unsigned int index); // removes A the node with Index index and returns the value that was removed o unsigned int search(node_t* head, unsigned int value); // Delivers the index of the node with the value Value; Implemented as sequential search o unsigned int searchBinary(node_t* head, unsigned int value); // Returns the index of the node with the value Value; Implemented as "Binary Search" o void printList(node_t* head); // Print the list to the console Be careful not to produce memory leaks when deleting nodes from the list will! So write a C program that: implants a doubly linked and sorted list implants each operation listed previously and demonstrats at least by one call o As a last test case you should generate 100 random numbers as values for the list, to show that your implementation can withstand arbitrary values output of an example:
Index 2 has value: 3 Index 3 has value: 5 Index 4 has value: 12 Index 5 has value: 18 Index 6 has value: 25 Index 7 has value: 42 Index 8 has value: 68 Index 9 has value: 100 Index 10 has value: 111 Index 11 has value: 999 Search for index of value 111 Index of value 111 is at 10 Search for index of value 111 with binary search... Index of value 111 is at 10 Reverse list... Index 0 has value: 999 Index 1 has value: 111 Index 2 has value: 100 Index 3 has value: 68 Index 4 has value: 42 Index 5 has value: 25 Index 6 has value: 18 Index 7 has value: 12 Index 8 has value: 5 Index 9 has value: 3 Index 10 has value: 3 Index 11 has value: 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started