title: Question regarding recursive stack while deleting middle element from stack
body: <p>I have the running code to remove the middle element from stack, that's not an issue. Here is my code;</p>
  
  <pre><code>def insert(stack,temp,curr,n):
  #print(curr,stack)
      if curr!=n//2:
         print(curr)
         stack.append(temp)
      #return
      return
  
  def delete_middle(stack,n,curr):
      while len(stack)&gt;0:
         temp=stack.pop()
         delete_middle(stack,n,curr+1)
         insert(stack,temp,curr,n)
      #print(stack)
         return stack
  
  delete_middle([2,4,1,18,34],5,0)
  </code></pre>
  
  <p>My code is working fine. But I am trying to understand how does the recursive stack work. For example, we are doing recursive call to <code>delete_middle()</code> around <code>5</code> times(same as length of list, <code>stack</code>). Each time the pointer variable , <code>curr</code> is updated to point at the current element. As you can see last value of <code>curr</code> will be 5, but since the length of stack is 0, there is no more recursive call. And then the <code>insert()</code> function is called.  </p>
  
  <p>Interestingly if I look at the values of <code>curr</code> inside <code>insert()</code>, we obtain following output;</p>
  
  <pre><code>4
  3
  2
  1
  0
  </code></pre>
  
  <p>Why is that we don't see the first value of <code>curr</code> as 5 here? I will highly appreciate some feedback here.And can I get some thoughts on its time complexity? It seems to be <code>O(N)</code> where <code>N</code> is size of the stack. But I am bit rusty about it. Will appreciate some insight here. 
  thanks</p>