538 views
0 0 votes

2 Answers

0 0 votes

Answer: 17

 

Taking any one element, using bruteforce logic, as average is asked, lets take element '4',

 

Now, above 4; 

 

First, we need to push 3,2,1 which takes 15(push-operation delay) + 3(intermediate operation delay) = 18

 

And also, we need to consider its pop operations, as the life of the element in stack is defined by its presence, pop 1,2,3 

                              which takes  33(pop-operation delay) + 3(intermediate operation delay) = 33

 

We get (18+33)/3 {as we are considering 3 elements here (1,2,3)}   =  17

 

 

Similarly for other elements as well we would get a similar average lifespan. 

 

Position:
Show:

Related questions

2 2 votes
2 2 answers
2.4k
2.4k views
Gurdeep Saini asked Jan 2, 2019
2,439 views
true/false ?) if stack is implemented as a array,all operation push ,pop ,is emptystack(),delete stack() can be performed in constant time.)if stack is implemented as a l...
1 1 vote
0 0 answers
2.8k
2.8k views
Na462 asked May 5, 2018
2,776 views
In implementation of queue using stack, deletion of second element from front take Ο(n) time, when insertion take Ο(1) time.Is it a true statement ?Well it can be true is...
7 7 votes
1 1 answer
353
353 views
GO Classes asked Jul 10
353 views
Assume there are $n$ elements in the data structure. Consider the following statements:$\text{S1}:$ A stack can be implemented using a linked list such that each individu...
3 3 votes
3 3 answers
8.6k
8.6k views
Ibtisam Sayyad asked Jan 12, 2018
8,568 views
What are the minimum enqueue and dequeue operations needed to perform pop operation for a stack which is implemented with two queues if there are already 10 elements in t...