• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE | Gate IT 2007 | Question 30

Suppose you are given an implementation of a queue of integers. The operations that can be performed on the queue are: 
i. isEmpty (Q) — returns true if the queue is empty, false otherwise. 
ii. delete (Q) — deletes the element at the front of the queue and returns its value. 
iii. insert (Q, i) — inserts the integer i at the rear of the queue. 
Consider the following function: 

C
 void f (queue Q) {
int i ;
if (!isEmpty(Q)) {
   i = delete(Q);
   f(Q);
   insert(Q, i);
  }
}

What operation is performed by the above function f ?

(A)

Leaves the queue Q unchanged

(B)

Reverses the order of the elements in the queue Q

(C)

Deletes the element at the front of the queue Q and inserts it at the rear keeping the other elements in the same order

(D)

Empties the queue Q

Answer

Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

Last Updated :
Share your thoughts in the comments