Here is my approach:
Stack lifetime of nth element -> Y
For (n-1)th -> 2X+2Y + stack lifetime of nth element = 2X + 3Y
For (n-2)th -> 2X+2Y + stack lifetime of (n-1)th element = 4X + 5Y
..
..
For 1st -> 2(n-1)X + (2n-1)Y
Sum of all life spans= (Σ 2(n-1)X) + (Σ (2n-1)Y) for n = 1 to n
Calculate sum by the above summation from 1 to n, You will get:
Sum = n(n(X+Y)-X)
Therefore Average = Sum/n = n(X+Y)-X . Hence Option (c)
source @ http://stackoverflow.com/questions/24464942/stack-life-span