Question: A double-ended queue supports operations like adding and removing items from both the sides of the queue. They support four operations like addFront(adding item to top of the queue), addRear(adding item to the bottom of the queue), removeFront(removing item from the top of the queue) and removeRear(removing item from the bottom 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? (Assume ‘m’ to be the size of the stack and ‘n’ to be the number of elements)
Options
A : O(m) and O(n)
B : O(1) and O(n)
C : O(n) and O(1)
D : O(n) and O(m)
Click to view Correct Answer
Data Structure Queue Using Stacks more questions
What is the time complexity of Fibonacci Search?
What is the space complexity of searching in a heap?
What is the time complexity of Jump Search?
What is the time complexity of enqueue operation?
You are asked to perform a queue operation using a....
The time complexity to perform the modular exponentiation of a....
Two balanced binary trees are given with m and n....
The construction time for DFA from an equivalent NFA (m....
In SW algorithm, to align two sequences of lengths of....
What is the best time complexity of bucket sort (k=....
Data Structure Adjacency List more Online Exam Quiz
Data Structure Propositional Directed Acyclic Word Graph
Data Structure Queue Linked List
Data Structure Queue Operations