/**
   This class sorts an array, using the merge sort 
   algorithm nonrecursively.
*/
public class MergeSorter
{
   private int[] a;

   /**
      Constructs a merge sorter.
      @param anArray the array to sort
   */
   public MergeSorter(int[] anArray)
   {
      a = anArray;
   }
   
   /**
      Sorts the array managed by this merge sorter.
   */  
   public void sort()
   { 
      int size = 1;
      
      int from = 0;
      int to = a.length - 1;       

      // Complete this for the draft
      while (size < to - from)
      { 
         for (...)
         {  
            merge(...);
         }
         size = 2 * size;
      }
   }
   
   public void merge(int from, int mid, int to)
   {       
      System.out.println("Merging " + from + "..." + mid 
	 + " and " + (mid + 1) + "..." + to);

      // Complete this method for the final submission
   }    
}
