Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Urgent C plz find struct node* pnumbers1 image text in transcribed
image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions