What does functionOfA(int a[]) do?
<p>I am currently trying to figure out what a certain method does so as to proceed to annotate it, providing a post condition and loop invariant.</p>

<p><strong>What I've figured out:</strong></p>

<ul>
<li><p>On a positive and negative array, all positive <code>x</code> becomes positive upon the first time the minimum is encountered.</p></li>
<li><p>When the array is all negative, <code>x</code> and <code>y</code> are the sum of the elements.</p></li>
</ul>

<p>Anyone see another approach to analyzing this method? Thank you for your time.</p>

<p>Java Code:</p>

<pre><code>public class funA {
    public static void functionOfA(int a[]) {
      int MAXINT = Integer.MAX_VALUE;
      int x = MAXINT; 
      int y = MAXINT; 
      int i = 0;
      int n = a.length;

      while(i != n) {
        if(y == MAXINT) {
          y = a[i];
          x = min(x, y);
          System.out.println("x: " + x + " y: " + y); 
          i= i+1;
        } else {
          y = min(y + a[i], a[i]);
          x= min(x, y);
          System.out.println("x: " + x + " y: " + y); 
          i= i+1;
        }  
      }
      System.out.println(x + " " + y);
  }

  public static int min(int x, int y) {
    if(x &lt; y) {
      return x;
    } else {
      return y;
    }
  }

  public static void main (String args[]) {
    int a[]= new int[] { 0, -9, 3, 2, -4, 3, -12, 3, 1 };
    functionOfA(a);
    for(int i= 0; i &lt; a.length; i++) {
      System.out.print(a[i]+ " ");
    }

    System.out.println();
    System.out.println();

    int a2[]= new int[] { -9, -3, -10, -4, -2 };
    functionOfA(a2);
    for(int i2 = 0; i2 &lt; a2.length; i2++) {
      System.out.print(a2[i2]+ " ");
    }
  }
}
</code></pre>

<p>By the way this was the given:</p>

<pre><code>int x = MAXINT; int y = MAXINT; int i = 0;
int a[n];

while (i != n) {
  y = min(y + a[i], a[i]);
  x = min(x, y);
  i = i + 1;
}
</code></pre>
