title: Declaring a shrink function in Dynamic Array in Stack
body: <p>Here is my code:</p>
  
  <pre><code>private void shrink(){ 
  int length = top+1; 
      if(length&lt;=MINCAPACITY || top&lt;&lt;2 &gt;= length)  
          return;
          length = length + (top&lt;&lt;1); 
          if(top &lt; MINCAPACITY) length = MINCAPACITY;
          int[] newstack = new int[length];
          System.arraycopy(stackRep, 0 , newstack, 0 , top+1);
          stackRep = newstack;
      }
  </code></pre>
  
  <p>In my book it is said that this operation shrinks the array to half if more than 3/4th empty. Can anyone please explain to me how is this taking place in this code? I suspect that this operation is taking place in the first if-statement and the length statement?</p>