Question: Use C program write a function( Node *merge_sorted_lists(Node *list 1, Node *list2) ) The output will looks like: You can optionally create the merge_sorted_lists function

Use C program write a function( Node *merge_sorted_lists(Node *list 1, Node *list2) )

Use C program write a function( Node *merge_sorted_lists(Node *list 1, Node *list2)

) The output will looks like: You can optionally create the merge_sorted_lists

function too for up to 10 bonus marks. This function should accept

The output will looks like:

two sorted lists as input (sorted from lowest to highest values). The

You can optionally create the merge_sorted_lists function too for up to 10 bonus marks. This function should accept two sorted lists as input (sorted from lowest to highest values). The function should return a pointer to a list that has been created by merging and connecting the nodes in the two lists to form a new list that is also sorted from lowest to highest. The new list should contain all of the nodes that are in both lists, what should be different is how the nodes point to each other in order to form one merged list. #include #include #include #include typedef struct node { int value; struct node *next; } Node; void print_list(Node *head); Node* insert_at_head (Node *head, int new_value); Node *merge_sorted_lists(Node *listi, Node *list2); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 int main() { printf(" merge_sorted_lists test "); printf(" ** "); srand(time(NULL)); Node *list11 = NULL; Node *list12 = NULL; for (int i = 0; i value = new_value; new_node->next = NULL; if (head NULL) return new_node; else { new_node->next = head; return new_node; } == 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 void print_list(Node *head) { Node *current; current = head; int i = 0; while (current != NULL) { printf("Node %d: %d ", i, current->value); current = current->next; i++; } } merre_sorted_lists test List 11... Node 0:3 Node 1: 6 Node 2: 8 Node 3: 12 Node 4: 38 Node 5: 47 Node 6: 48 Node 7: 55 Node 8: 69 Node 9: 79 List 12... Node 0: 17 Node 1: 49 Node 2: 57 Node 3: 61 Node 4: 71 Node 5: 78 Node 6: 80 Node 7: 84 Node 8: 89 Node 9: 95 Merged list... Node 0: 3 Node 1: 6 Node 2: 8 Node 3: 12 Node 4: 17 Node 5: 38 Node 6: 47 Node 7: 48 Node 8: 49 Node 9: 55 Node 10: 57 Node 11: 61 Node 12: 69 Node 13: 71 Node 14: 78 Node 15: 79 Node 16: 80 Node 17: 84 Node 18: 89 Node 19: 95

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!