Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( 1 0 % ) Consider the function func as shown below, where the two lists list 1 and list 2 are both ordered in

(10%) Consider the function func as shown below, where the two lists list 1 and list 2 are both ordered in ascending order.
struct item
{
int value;
struct item *next;
};
int func (struct item *list1, struct item *list2)
{
struct item *ptr1,*ptr2;
int count =0;
ptr1= list 1 ;
ptr2= list2;
while ((ptrl != NULL) &&&(ptr2 NULL))
{
if (ptrl->value ptr2->value)
ptrl = ptrl next;
else if (ptrl->value > ptrz->value)
ptr 2= ptr 2 next
else
{
ptr 1= ptr 1 next ;
ptr2= ptr 2 next ;
}
count ++;
}
return count;
}
If m and n are the number of items in list 1 and list 2 respectively, what is the worstcase time complexity of func(list 1, list 2)?
image text in transcribed

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

Students also viewed these Databases questions