+1 vote
in Data Structures & Algorithms I by (110k points)
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

This key question is from Queue using Stacks topic in portion Abstract Data Types of Data Structures & Algorithms I

I have been asked this question in homework.

1 Answer

+1 vote
by (412k points)
selected by
 
Best answer
The correct answer is (a) Because of its time complexity O(n)

The explanation is: 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.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...