edited by
822 views
1 votes
1 votes
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
edited by

Please log in or register to answer this question.

Related questions

0 votes
0 votes
1 answer
1
Rackson asked Jan 12, 2019
970 views
0 votes
0 votes
1 answer
2
0 votes
0 votes
1 answer
3
HeadShot asked Nov 12, 2018
467 views
Why ?Isnt Option A true using "Binary search"
0 votes
0 votes
0 answers
4