Time Left - 15:00 mins

GATE 2022 : Data Structure and Programming Quiz - 7

Attempt now to get your rank among 324 students!

Question 1

Consider a circular queue where the empty spaces are utilized in a queue in effective manner. Now circular queue maintains two pointers front and rear . What is the condition for the circular queue to be full ?

Question 2

Consider the following function.
Void gradeup(int n)
{
   enqueue(Q,0);
   enqueue(Q,1);
for (i=0;i<n;i++)
{
   x = dequeue(Q);
   y = dequeue(Q);
   enqueue(Q,y);
   enqueue(Q,x+y);
   print(x);
}
}
What is the functionality of above function gradeup?

Question 3

In a network there are two stations A and B, A is sending data packets to B in order one by one, but B is working very slowly so which data structure will B require as to maintain integrity of data?

Question 4

The data structure queue is used in which of the following?

Question 5

Consider the implementation of a queue Q with the help of two stacks S1 and S2. Implementation is done such that the enqueue (1 enqueue is equivalent to 1 push in S1) operation of Q will take O(1) time and dequeue operation (1 dequeue is equal to pop from S2 , if S2 is empty then first pop from S1 , push into S2 one by one and then pop from S2) will take O(n) time.

Now if following operations are performed in series on this queue Q, then find the number of total push operations?

5 Enqueue, 3 Dequeue, 8 Enqueue, 7 Dequeue, 15 Enqueue, 14 Dequeue.

Question 6

Consider a queue with two pointers i.e. front and rear. To utilize the space better, we use circular queue which uses the empty slot present in queue. Currently the status of queue is:

Front Pointer, F = 3

Rear Pointer, R = 5

Now 3 elements a , b and c are inserted in the circular queue and 2 elements are removed from queue. What is the final position of the front pointer ________.

  • 324 attempts
  • 0 upvotes
  • 3 comments
Jul 28GATE & PSU CS