title: Non-recursive Merge Sort using Stacks
body: <p>I'm currently working on an assignment where I am supposed to write mergeSort using stacks! I have a pretty good idea on how stacks and mergesort works, however I am not sure how to finish my code with stacks. I've set up a base case, and here I'm trying to use an in-place method where I just theoretically divide up my array without creating a new one by changing the markers. I am pretty new to this and unsure of how I should proceed.. 
  I think this is the sort of thing I'm going for :</p>
  
  <p>Base Case --> PC = 1</p>
  
  <pre><code>if (callStack.peek().PC == 1) {
              if (callStack.peek().start == callStack.peek().stop) {   //length &lt;=1 
                  callStack.pop(); //either done, or array length was 1
                  merge(A, callStack.peek().start, callStack.peek().mid, callStack.peek().stop);
  
                  if (callStack.empty()){
                      break;
                  }
                  callStack.peek().PC++;
              } else {
                  callStack.peek().PC++;
              }
              continue;
          }`
  </code></pre>
  
  <p>any left divided array --> PC = 2
  any right divided array --> PC == 3</p>
  
  <pre><code>int mid = (callStack.peek().stop-callStack.peek().start)/2;
  
          if (callStack.peek().PC == 2) {
              if (callStack.peek().start != callStack.peek().stop) {
              current = new ProgramFrame(callStack.peek().start, callStack.peek().mid, 1);
              callStack.push(current);
              continue;
              }
          }
  
          if (callStack.peek().PC == 3) {
              if (callStack.peek().start != callStack.peek().stop) {
              current = new ProgramFrame(callStack.peek().mid+1, callStack.peek().stop, 1);
              callStack.push(current);
              continue;
              }
          }
  </code></pre>
  
  <p>the merged of both --> PC ==4 </p>
  
  <p>if (callStack.peek().PC == 4) {
                  merge(A, callStack.peek().start, callStack.peek().mid, callStack.peek().stop);</p>
  
  <pre><code>            callStack.pop();
  
              if (!callStack.empty()) {
                  if (callStack.peek().PC == 2) callStack.peek().start callStack.peek().mid; //help??
                  if (callStack.peek().PC == 3) callStack.peek().mid+1, callStack.peek().stop; //help??
                  callStack.peek().PC++;
                  continue;
  </code></pre>
  
  <p>I'm sorry this is such a long post :( I am just really unsure of how to fix it and how to continue it...</p>
  
  <p>** also merge and my programeFrame look okay, but if you need to see them I can send them too! </p>