### Chapter 18 Linked Lists, Stacks, Queues, and Priority Queues

*18.1*________ is a data structure to store data in a sequential order.

*18.2*If a pointer p does not point to anything, assign ________ to p.

*18.3*If a list is empty, which of following statements are true?

*18.4*Which of the following operations are supported by a list?

*18.5*list is more efficient than LinkedList for the following operations:

*18.6*LinkedList is more efficient than list for the following operations:

*18.7*Suppose list1 is a list and list2 is a LinkedList. Both contains 1 million double values. Analyze the following code:

A:

while len(list1) > 0:

del list1[0]

B:

while list2.getSize() > 0:

list2.removeFirst()

*18.8*Suppose list1 is a list. Analyze the following code:

A:

while len(list1) > 0:

del list1[len(list1) - 1]

B:

while len(list1) > 0:

list1.remove(list1.get(len(list1) - 1))

*18.9*Suppose list1 is a list and list2 is a LinkedList. Both contains 1 million double values. Analyze the following code:

A:

while len(list1) > 0:

del list1[len(list1) - 1]

B:

while list2.getSize() > 0:

list2.removeLast()

*18.10*Suppose list2 is a LinkedList. Analyze the following code:

A:

while len(list2) > 0:

list2.remove(list2.get(len(list2) - 1))

B:

while list2.getSize() > 0:

list2.removeLast()

*18.11*Suppose list1 is a list and list2 is a LinkedList. Both contains 1 million double values. Analyze the following code:

A:

for i in range(100000):

list1.insert(0, i)

B:

for i in range(100000):

list2.insert(0, i);

*18.12*Suppose list1 is a list and list2 is a LinkedList. Both contains 1 million double values. Analyze the following code:

A:

for i in range(100000):

list1.append(i);

B:

for i in range(100000):

list2.add(i);

*18.13*Suppose list1 is a list and list2 is a LinkedList. Both contains 1 million double values. Analyze the following code:

A:

for i in range(100000):

sum += list1[i];

B:

for i in range(100000):

sum += list2.get(i);

*18.14*Which of the following are true?

*18.15*Which of the following are true?

*18.16*Which of the following are true?

*18.17*In the implementation of Stack and Queue, which of the following are true?

*18.18*Which data structure is appropriate to store patients in an emergency room?

*18.19*Which data structure is appropriate to store customers in a clinic for taking flu shots?

*18.20*Suppose the rule of the party is that the participants who arrive later will leave earlier. Which data structure is appropriate to store the participants?