1,082 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

1 1 vote
1 1 answer
293
293 views
khanshahima4 asked Sep 24
293 views
1. If precedence tells me which operator has priority, and associativity tells me how to handle operators at the same level, then why do I need a separate concept called ...
14 14 votes
1 1 answer
1.4k
1.4k views
GO Classes asked Jul 2
1,360 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 ...
18 18 votes
2 2 answers
756
756 views
GO Classes asked Jul 2
756 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}$...
10 10 votes
1 1 answer
563
563 views
GO Classes asked Jul 2
563 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 ...