530 views
Consider a stack with 100 elements present. Suppose in a scenario, we are required to remove the first inserted element in it, which is done by POP operations followed by PUSH operations with intermediate elements temporarily being saved in an array. After $10$ such removals, without anyother intermediate PUSH/POP operations, total number of PUSH operations required is ______

### 1 comment

What question says is

100 elements are already present in the stack. Say in the bottom up manner from 1,2,3, . . . 100.

Now to remove 1 we need to do 100 pop operation and then save remaining 99 elements to temporary location (as not specified to save it to another stack) and then again push those 99 elements to stack again.

So now the stack has elements 2,3,4,. . .,100. Now to remove 2 we again follow the same procedure so we will end up with 99 pop operations followed by 98 push operations.

Continuing this to 10 times we will get no of $\textbf{PUSH = }$ 99 + 98 + . . . + 90 = 945

Initially we do 100 POP followed by 99 PUSH.

For 10 such operations we would do

$99 + 98 + 97+96+95+94+93+92+91+90 = 900+45 = 945$ PUSH operations.
by

90*10 + (0+1+2+3+4+5+6+7+8+9)=945
I could not understand the question itself. Can someone please explain