Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose L is a LIST and p, q, and r are positions. As a function of n, the lengt

ID: 638432 • Letter: S

Question

Suppose L is a LIST and p, q, and r are positions. As a function of n, the length of list L, determine how many times the functions FIRST, END, and NEXT are executed by the following program.

                p := FIRST(L);

                while p <> END(L) do begin

                        q := p;

                       while q <> END(L) do begin

                                q := NEXT(q, L);

                                r := FIRST(L);

                                while r <> q do

                                                r := NEXT(r, L)

                       end;

                        p := NEXT(p, L)

                end;

Explanation / Answer

FIRST() function will be called 2 times ,NEXT function will be called 5 times and finally END() function will be called 2 times

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote