Question: The previous question is 2. (Dynamic linked lists) Extend the C-program from the previous exercise to spit the linked list in two halves and output


2. (Dynamic linked lists) Extend the C-program from the previous exercise to spit the linked list in two halves and output the result If the list has an odd number of elements, then the first I Note that - your algorithm should be 'in-place' (so you are not permitted to create a second linked list or use some other data structure such as an array); - you should not traverse the list more than once (e.g to count the number of elements and then restart from the beginning) 2. (Dynamic linked lists) Extend the C-program from the previous exercise to splt the linked list in two halves and output the result. If the list has an odd number of elements, then the first I Note that - your algorithm should be 'in-place' (so you are not permitted to create a second linked list or use some other data structure such as an array); - you should not traverse the list more than once (e.g to count the number of elements and then restart from the beginning) Write a C-program called llereate.c that creates a linked list of integers from user input. Your program should use the following functions: - vaid freeLl(NodeT "list): taken from the lecture. - void showLL(Node T " "ist): taken from the lecture but needs modification. - NodeT "joinLL(NodeT "ist, int v): returns a pointer to the linked list obtained by appending a new element with data v at the end of list. Needs to be implemented. The program - starts with an empty linked list called a11 (say), initialised to NULL - prompts the user with the message "Enter an integer:" - appends at the end of a11 a new linked list node created from user's response - asks for more user input and repeats the cycle - the cycle is terminated when the user enters any non-numeric character " on termination, the program generates the message "Done. List is" followed by the contents of the linked list in the format shown below A sample interaction is: prompts //11 create Enter an integer: 12 Enter an integer: 34 Enter an integer: 56 Enter an integer: quit Done. List is 12>34>56 Note that any non-numeric data 'finishes' the interaction. If the user provides no data, then no list should be output: prompts./11create Enter an integer: Done
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
