Q. 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:
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
πŸ’¬ Discuss
βœ… Correct Answer: (B) reverses the order of the elements in the queue q

You must be Logged in to update hint/solution

πŸ’¬ Discussion

πŸ“Š Question Analytics

πŸ‘οΈ
884
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
99%
Success Rate