Why is implementation of stack operations on queues not feasible for a large dataset (Asssume the number of elements in the stack to be

Hoàng Minh An

New member
Why is implementation of stack operations on queues not feasible for a large dataset (Asssume the number of elements in the stack to be n)?
A. Because of its time complexity O(n)
B. Because of its time complexity O(log(n))
C. Extra memory is not required
D. There are no problems
 
Answer: A
Explanation: To perform Queue operations such as enQueue and deQueue there is a need of emptying all the elements of a current stack and pushing elements into the next stack and vice versa. Therfore it has a time complexity of O(n) and the need of extra stack as well, may not be feasible for a large dataset.
 

Tìm kiếm

Back
Top