CSC 212 Ch 8 Multiple Choice

¡Supera tus tareas y exámenes ahora con Quizwiz!

In the linked list implementation of the queue class, where does the push member function place the new entry on the linked list?

At the tail

In the circular array version of the queue class (with a fixed-sized array), which operations require linear time for their worst-case behavior?

None of these operations require linear time. (front, push, empty)

In the linked-list version of the queue class, which operations require linear time for their worst-case behavior?

None of these operations require linear time. (front, push, empty)

I have implemented the queue with a linked list, keeping track of a front pointer and a rear pointer. Which of these pointers will change during an insertion into a NONEMPTY queue?

Only rear_ptr changes.

One difference between a queue and a stack is:

Queues use two ends of the structure; stacks use only one.

Consider the implementation of the queue using a circular array. What goes wrong if we try to keep all the items at the front of a partially-filled array (so that data[0] is always the front).

The get_front function would require linear time.

Suppose we have a circular array implementation of the queue class, with ten items in the queue stored at data[2] through data[11]. The CAPACITY is 42. Where does the push member function place the new entry in the array?

data[12]

If data is a circular array of CAPACITY elements, and last is an index into that array, what is the formula for the index after last?

(last + 1) % CAPACITY

Suppose top is called on a priority queue that has exactly two entries with equal priority. How is the return value of top selected?

This can never happen (violates the precondition)

Which of the following expressions evaluates to true with approximate probability equal to P? (P is double and 0 <= P <= 1).

rand() < P

I have implemented the queue with a linked list, keeping track of a front pointer and a rear pointer. Which of these pointers will change during an insertion into an EMPTY queue?

Both change (the rear_ptr and the front_ptr)

If the characters 'D', 'C', 'B', 'A' are placed in a queue (in that order), and then removed one at a time, in what order will they be removed?

DCBA

I have implemented the queue with a circular array, keeping track of first, last, and count (the number of items in the array). Suppose first is zero, and last is CAPACITY-1. What can you tell me about count?

count could be zero or CAPACITY, but no other values could occur.


Conjuntos de estudio relacionados

Chapter 14 Adaptive pre-test and Q&A's

View Set

WEEK 1 :: SEO :: Getting Started & Introduction to SEO

View Set

APUSH Semester 2, Test 1: Jacksonianism and Marshall Court

View Set

Chapter 5 - Sourcing and Recruiting

View Set

11.7 Fundamental Counting Principles

View Set

Chapter 2: Money management strategy: Financial

View Set