1) Write a function that merges two instances of the List ADT using the following specifications:
MergeList (List list1, List list2, List& result)
• list1 and list2 have been initialized and are sorted using function ComparedTo
• result is a sorted list that contains all of the items
a. Write the prototype for MergeLists.
b. Write the function definition, using an array-based implementation.
c. Write the function definition, using a linked implementation.
d. Describe the algorithm in terms of Big-O.
I think I've got some of this right but im not so sure about Lists or exactly what shes looking for on the prototype.
This is for the prototype.
void Merge(int[], int[], int[]);
This is the code for b that i have so far.
void Merge(int*list1[], int*list2[],int*listResult[])
{
int num1 =0;
int num2 =0;
int num3 =0;
while((num1<list1.length()) && (num2<list2.length())
{
if(list1[num1]<list2[num2])
{
listResult[num3]=list1[num1];
num1++;
}
else
{
listResult[num3]=list2[num2];
num2++;
}
num3++;
}
while(num2<list2.length())
{
listResult[num3] = list2[num2];
num2++;
num3++;
}
while(num1<list1.length())
{
listResult[num3] = list1[num1];
num1++;
num3++;
}
}
As for the rest im pretty lost. Any help would be appreciated.