Question: Write a subroutine with the name double in C that doubles the nodes between two given index in a linked list by inserting a new
Write a subroutine with the name double in C that doubles the nodes between two given index in a linked list by inserting a new node with the same element (value) after one node. The nodes are given by:
struct nodeEl {
int el;
struct nodeEl * next;
};
typedef struct nodeEl node;
The list head (of the type: node * ), is the first parameter of the subroutine. The second and third parameters consist of start index and end index. Example: If the list from the beginning is (4,5,2,3,8,9) it becomes after the call to double with start index 2 and end index 4 (4,5,2,2,3,3,8,8,9 ).
A suitable precondition for the method is that the start- and end index is greater than or equal to 0 and less than the size of the list and that start index is less than or equal to the final index.
The subroutine should be written without using library functions (the exceptions are malloc and free if they needed). It is allowed to define help functions. Also write an explanation of how the subroutine works.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
