next up previous
Nächste Seite: Bubble-Sort (II) Aufwärts: Grundlagen der Java-Programmierung (Vorlesung Vorherige Seite: Beispiele

Bubble-Sort

$ $Id: bubble.tex,v 1.1 2003/11/07 00:02:26 joe Exp $ $

static void swap (int [] a, int x, int y) {
// vertausche a[x] mit a[y]
   int h = a[x]; 
   a[x] = a[y]; a[y]=h;
}

static void bubble (int [] a, int x, int y) {
// stellt a[x] <= a[y] her
    if (a[x] > a[y]) {
         swap (a, x, y);   
    }
}



Johannes Waldmann 2004-01-30