Menu

Queues Questions

MCQ
31.
A linear list of elements in which deletion can be done from one end (front) and insertion can take place only at the other end (rear) is known as a ?
forum Discussion
MCQ
32.
The data structure required for Breadth First Traversal on a graph is?
forum Discussion
MCQ
33.
A queue is a ?
forum Discussion
MCQ
34.
A data structure in which elements can be inserted or deleted at/from both the ends but not in the middle is?
forum Discussion
MCQ
35.
Which of the following properties is associated with a queue?
forum Discussion
MCQ
36.
In a circular queue, how do you increment the rear end of the queue?
forum Discussion
MCQ
37.
What is the term for inserting into a full queue known as?
forum Discussion
MCQ
38.
What is the time complexity of enqueue operation?
forum Discussion
MCQ
39.
What is the need for a circular queue?
forum Discussion
MCQ
40.
Which of the following best describes the growth of a linear queue at runtime?

 (Q is the original queue, size() returns the number of elements in the queue)

a)

private void expand()
{
 int length = size();
 int[] newQ = new int[length<<1];
 for(int i=front; i<=rear; i++)
 {
  newQ[i-front] = Q[i%CAPACITY];
 }
 Q = newQ;
 front = 0;
 rear = size()-1;
}

b)

private void expand()
{
 int length = size();
 int[] newQ = new int[length<<1];
 for(int i=front; i<=rear; i++)
 {
  newQ[i-front] = Q[i%CAPACITY];
 }
 Q = newQ;
}

c)

private void expand()
{
 int length = size();
 int[] newQ = new int[length<<1];
 for(int i=front; i<=rear; i++)
 {
  newQ[i-front] = Q[i];
 }
 Q = newQ;
 front = 0;
 rear = size()-1;
}

d)

private void expand()
{
 int length = size();
 int[] newQ = new int[length*2];
 for(int i=front; i<=rear; i++)
 {
  newQ[i-front] = Q[i%CAPACITY];
 }
 Q = newQ;
}
forum Discussion