You are given a Linked list L, and another linked list, P, containing integers, sorted in ascending order. The operation print – lots (L,P) will print the elements in L that are in position specified by P. for instance, if P = 1, 3, 4, 6, the first, third, forth and sixth elements in L are printed. What is the running time of this routine?
Printlots (List L, List P)
{
int counter:
position Lpos, Ppos ;
Lpos = First (L);
Ppos = First (P);
Counter = 1;
while (Lpos! = NULL && Ppos ! = NULL)
{
if (Ppos → Element = = counter ++)
{
printf (“%d”, Lpos→ Element)
Ppos = next (Ppos, P);
}
Lpos = Next (Lpos, L);
}
}
A)O(L)
B)O(L+P)
C)O(P)
D)none