Question: Urgent C plz find struct node* pnumbers1 Use the attached code below. In this lab exam, you are going to implement mergeLists function. This function


Use the attached code below. In this lab exam, you are going to implement mergeLists function. This function aims to merge 2 sorted lists. Assume that input lists to mergelists is sorted. You are going to use input.txt as input to the program. Example: When list1->1 34679 and list2->245 the output merged list will be list3->123445679. In this program, allocation is done in a smart fashion, and count of memory allocated is kept track. And in the implementation of the function mergelists, you must use already allocated memory and you are not going to allocate any extra memory. Hence: list 1134679 and list 2>245 at the end of first iteration, it will be list1->3 4679 , list2->2 45 , list3->1 You will change the pointers, and do not need to allocate extra memory. Since you are always inserting to the end of list3, you can keep track of a temporary pointer as tail to ease insert at the end of the list, and not to traverse list 3 till the end at each insert. At the end of the program, ensure that Allocated memory is 0. \} printf("List 1: "); printList(head1); printf("List 2: "); printList(head2); printf("Memory Allocated before merge : od ", countsAllocated); head3 = mergeLists(head1, head2); printf("List 3: "); printList(head3); freelist(\&head3); printf("Memory Allocated after free : od ", countsAllocated); \} f.close (inFile)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
