1,067 views
1 1 vote
Let S be a stack k of size n > 1. Starting with the empty stack, suppose we push the
first n natural numbers in sequence, and then perform n pop operations. Assume
that Push and Pop operation take X seconds each , and Y seconds elapse between
the end of the one such stack operation and the start of the next operation. For
m > 1, define the stack-life of mcs the time elapsed from the end or Push (m) to
the start of the pop operation that removes m from S . The average stack-life of
an element of this stack is
(A) n(X+Y) (B) 3Y+2X
(C) n(X+Y)-X (D) Y+ 2X

1 Answer

0 0 votes
here numbers are entered in natural order from 1,2,---------n these are coming in AP so simply do this.... first first element 1... n-1  nelements has to push and n-1 elements has to pop so total time=2(n-1)X and b/w each y sec elapse so total elapse=[2(n-1)+1]Y.

 now for last element just y unit elapse...so total time=2(n-1)x+2(n-1)y+y+[y]/2=n(x+y)-x
Position:
Show:

Related questions

13 13 votes
1 1 answer
1.2k
1.2k views
GO Classes asked Jul 2
1,170 views
Assume:$\texttt{short = 2 bytes}$, $\texttt{int = 4 bytes}$, $\texttt{char = 1 byte}$$\texttt{int}$ needs $4$-byte alignment and the final structure size is rounded to a ...
15 15 votes
2 2 answers
624
624 views
GO Classes asked Jul 2
624 views
Assume:struct Student { double gpa; }; struct Student alice; struct Student *sptr = &alice;Which of the following correctly assigns $\texttt{4.0}$ to $\texttt{alice.gpa}$...
9 9 votes
1 1 answer
465
465 views
GO Classes asked Jul 2
465 views
Consider the following code idea from the source:typedef struct { double x, y; } Point; void reset(Point p) { p.x = p.y = 0; } int main() { Point a = {12.0, 42.0}; Point ...
6 6 votes
1 1 answer
444
444 views
GO Classes asked Jul 2
444 views
What is printed by the following program?#include <stdio.h struct Student { int id, year; char grade; }; int main() { struct Student s; s.id = 10001; s.year = 2010; s.gra...