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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.