Stack life

Let S S be a stack of size greater than 1 1 . Starting from an empty stack, suppose we push the first n n natural numbers in sequence and then perform n n pop operations. For 1 x n 1\leq x\leq n the stack life of x x is defined as the time taken from the end of push(x) to the start of the pop operation that removes x x from S S . What of the following is the correct representation for the average stack life of x x ?

Details and Assumptions

  • k k is the number of seconds required to pop and push an item
  • l l is the number of seconds elapsed between each successive operations.
n ( k + l ) n(k+l) 2 n ( k + l ) 2n(k+l) n ( k + l ) k n(k+l)-k n ( k + 2 l ) n(k+2l)

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

You Kad
Jul 29, 2016

Stack Life Drawing Stack Life Drawing The stack life of x = 1 x = 1 is equal to 2 ( n 1 ) ( k + l ) + l = ( 2 n 1 ) ( k + l ) k 2(n-1)(k + l) + l = (2n-1)(k+l) - k (see the drawing).

Likewise, the stack life of i [ 1 , n ] N i \in [1, n] \cap \mathbb{N} is equal to 2 ( n i ) ( k + l ) + l = ( 2 n 2 i + 1 ) ( k + l ) k 2(n-i)(k + l) + l = (2n-2i + 1)(k+l) - k

Therefore, the average stack life is :

1 n i = 1 n ( ( 2 n + 1 ) ( k + l ) k 2 i ( k + l ) ) = ( 2 n + 1 ) ( k + l ) k 1 n 2 ( k + l ) n ( n + 1 ) 2 = n ( k + l ) k \displaystyle \dfrac{1}{n} \sum\limits_{i = 1}^n \Big( (2n + 1)(k+l) - k - 2i(k+l) \Big) = (2n + 1)(k+l) - k - \frac{1}{n}\frac{2(k+l)n(n+1)}{2} = n(k+l) - k

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...