title: Finding max and min using divide and conquer approach
body: <p>I know this is a silly question,but I'm not getting this at all.
  In this code taken from <a href="http://somnathkayal.blogspot.in/2012/08/finding-maximum-and-minimum-using.html" rel="nofollow">http://somnathkayal.blogspot.in/2012/08/finding-maximum-and-minimum-using.html</a></p>
  
  <pre><code>public int[] maxMin(int[] a,int i,int j,int max,int min) {
      int mid,max1,min1;
      int result[] = new int[2];
  
      //Small(P)
      if (i==j) max = min = a[i];
      else if (i==j-1) { // Another case of Small(P)
          if (a[i] &lt; a[j]) {
              this.max = getMax(this.max,a[j]);
              this.min = getMin(this.min,a[i]); 
          }
          else {
              this.max = getMax(this.max,a[i]); 
              this.min = getMin(this.min,a[j]); }
          } else {
              // if P is not small, divide P into sub-problems.
              // Find where to split the set.
  
              mid = (i + j) / 2;
              // Solve the sub-problems.
              max1 = min1 = a[mid+1];
              maxMin( a, i, mid, max, min );    
              maxMin( a, mid+1, j, max1, min1 );
  
              // Combine the solutions.
              if (this.max &lt; max1) this.max = max1;
              if (this.min &gt; min1) this.min = min1;
          }
  
          result[0] = this.max;
          result[1] = this.min;
          return result;
      }
  }
  </code></pre>
  
  <p>Let's say the array is 8,5,3,7 and we have to find max and min,
  Initial values of max and min=arr[0]=8;
  First time list will be divided into 8,5
  We call MaxMin with max=8 and min=8,since i==j-1,we will get max=8,min=5,</p>
  
  <p>Next time list will be divided into [3,7],
  min1=max1=arr[mid+1]=3,
  We call MaxMin with max=3 and min=3.Since i is equal to j-1,we will get max=7,min=3,</p>
  
  <p>Next the comparison is performed between max1,max and min1,min ,
  Here is my confusion,
  The values of max and max1 here is 8 and 7 respectively,but how???
  We have not modified max1 anywhere,then how it will have a value 7,</p>
  
  <p>As per my understanding,we had called MaxMin with max=3 and min=3 and then updated max=7 and min=3,but we had not returned these updated values,then how the values of max1 and min1 got updated,
  I'm stuck at this,please explain.
  Thanks.</p>