📚 Question Bank Q75 — Programming and Data Structure
Tags
Programming and Data Structure
Q75. Marks: +2.0 UGC NET Paper 2: Computer Science 26th Nov 2021
A double‐ended queue (dequeue) supports adding and removing items from both the ends of the queue. The operations supported by dequeue are AddFront(adding item to front of the queue), AddRear(adding item to the rear of the queue), RemoveFront(removing item from the front of the queue), and RemoveRear(removing item from the rear of the queue). You are given only stacks to implement this data structure. You can implement only push and pop operations. What’s the time complexity of performing AddFront() and AddRear() assuming m is the size of the stack and n is the number of elements?
1.O(m) and O(n)
2.O(1) and O(n) ✓ Correct
3.O(n) and O(1)
4.O(n) and O(m)
📄 All “Programming and Data Structure” questions across papers
🏷 Change Tag for this Question