next up previous
Next: About this document ... Up: No Title Previous: Exercice 2

Exercice 3

static int[] fusion(int[] a, int[] b) {
  int i= 0, j= 0;
  int[] c= new int[a.length + b.length);
  while (i+j < c.length) {
    if ( i < a.length && a[i] < b[j]) { c[i+j]=a[i]; i++;}
    else { c[i+j]=b[j]; j++;}
  }
  return c;
}


Dominique Perrin
1998-11-18