Question: How many times does Loop 1 iterate on input lists A = ( 2 , 7 , 1 1 , 1 6 , 2 1

How many times does Loop 1 iterate on input lists A =(2,7,11,16,21) and B =(3,4,6,9,13)? For all lists, items are removed from the front and added to the back. The front of the list is one the left and the back is on the right, so 2 is at the front of list A and 21 is at the back of list A .
// Loop 1:
While( size(A)>0 AND size(B)>0)
If ( front(A)< front(B)), then x := remove(A)
If ( front(A) front(B)), then x := remove(B)
add(x, C)
End-while
a.
5
b.
7
c.
8
d.
10
a.
24,13,18,24
b.
24,13,18
c.
24,18,24
d.
24,13,18,18

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!