Animation of Bubble Sort

  • Published on
    09-Feb-2016

  • View
    28

  • Download
    0

Embed Size (px)

DESCRIPTION

Animation of Bubble Sort. Steven Strecker CS510 Computer Algorithms. Kalamazoo College. Introduction. void bubble(itemType a[], int N) { int i, j; for (i = N; i >= 1; i--) for (j = 2; j a[j]) - PowerPoint PPT Presentation

Transcript

  • Animation of Bubble SortSteven Strecker

    CS510 Computer AlgorithmsKalamazoo College

  • Introductionvoid bubble(itemType a[], int N){ int i, j; for (i = N; i >= 1; i--) for (j = 2; j a[j]) swap(a, j-1, j);}

  • A N E X A M P L Evoid bubbles(itemtype a[], int n) bubbles(a[], 9){ int i, j; for (i = n; i >= 1; i--) for ( i = 9; i >= 1; i--) for (j = 2; j a[2] no swap(a, j-1, j);}

  • A N E X A M P L Evoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for ( i = 9; i >= 1; i--) for (j = 2; j a[3]) YES swap(a, j-1, j);}

  • A E N X A M P L E void bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for ( i = 9; i >= 1; i--) for (j = 2; j a[3]) YES swap(a, j-1, j); swap(a, 2, 3)}

  • A E N X A M P L Evoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for ( i = 9; i >= 1; i--) for (j = 2; j a[4]) NO swap(a, j-1, j); }

  • A E N X A M P L Evoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for ( i = 9; i >= 1; i--) for (j = 2; j a[5]) YES swap(a, j-1, j);}

  • A E N A X M P L E void bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for ( i = 9; i >= 1; i--) for (j = 2; j a[5]) YES swap(a, j-1, j); swap(a, 4, 5); }

  • A E N A X M P L Evoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for ( i = 9; i >= 1; i--) for (j = 2; j a[6]) YES swap(a, j-1, j);}

  • A E N A M X P L E void bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for ( i = 9; i >= 1; i--) for (j = 2; j a[6]) YES swap(a, j-1, j); swap(a, 5, 6); }

  • A E N A M X P L Evoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for ( i = 9; i >= 1; i--) for (j = 2; j a[7]) YES swap(a, j-1, j);}

  • A E N A M P X L E void bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for ( i = 9; i >= 1; i--) for (j = 2; j a[7]) YES swap(a, j-1, j); swap(a, 6, 7); }

  • A E N A M P X L Evoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for ( i = 9; i >= 1; i--) for (j = 2; j a[8]) YES swap(a, j-1, j);}

  • A E N A M P L X E void bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for ( i = 9; i >= 1; i--) for (j = 2; j a[8]) YES swap(a, j-1, j); swap(a, 7, 8); }

  • A E N A M P L X Evoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for ( i = 9; i >= 1; i--) for (j = 2; j a[9]) YES swap(a, j-1, j);}

  • A E N A M P L E X void bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for ( i = 9; i >= 1; i--) for (j = 2; j a[9]) YES swap(a, j-1, j); swap(a, 8, 9); }

  • A E N A M P L E Xvoid bubbles(itemType a[], int N){ int i, j; for (i = N; i >= 1; i--) for (j = 2; j a[j]) swap(a, j-1, j);}

  • A E N A M P L E Xvoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for (i = 9; i>=1; i--) for (j = 2; j a[2]) NO swap(a, j-1, j); }

  • A E N A M P L E Xvoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for (i = 9; i>=1; i--) for (j = 2; j a[3]) NO swap(a, j-1, j); }

  • A E N A M P L E Xvoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for (i = 9; i>=1; i--) for (j = 2; j a[4]) YES swap(a, j-1, j);}

  • A E A N M P L E X void bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for (i = 9; i>=1; i--) for (j = 2; j a[4]) YES swap(a, j-1, j); swap(a, 3, 4) }

  • A E A N M P L E Xvoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for (i = 9; i>=1; i--) for (j = 2; j a[5]) YES swap(a, j-1, j);}

  • A E A M N P L E X void bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for (i = 9; i>=1; i--) for (j = 2; j a[5]) YES swap(a, j-1, j); swap(a, 4, 5) }

  • A E A M N P L E Xvoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for (i = 9; i>=1; i--) for (j = 2; j a[6]) NO swap(a, j-1, j); }

  • A E A M N P L E Xvoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for (i = 9; i>=1; i--) for (j = 2; j a[7]) YES swap(a, j-1, j);}

  • A E A M N L P E Xvoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for (i = 9; i>=1; i--) for (j = 2; j a[7]) YES swap(a, j-1, j); swap(a, 6, 7)}

  • A E A M N L P E Xvoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for (i = 9; i>=1; i--) for (j = 2; j a[8]) YES swap(a, j-1, j);}

  • A E A M N L E P Xvoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for (i = 9; i>=1; i--) for (j = 2; j a[8]) YES swap(a, j-1, j); swap(a, 7, 8)}

  • A E A M N L E P Xvoid bubbles(itemType a[], int N){ int i, j; for (i = N; i >= 1; i--) for (j = 2; j a[j]) swap(a, j-1, j); }

  • A E A M N L E P Xvoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for (i = 9; i>=1; i--) for (j = 2; j a[2]) NO swap(a, j-1, j); }

  • A E A M N L E P Xvoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for (i = 9; i>=1; i--) for (j = 2; j a[3]) YES swap(a, j-1, j);}

  • A A E M N L E P Xvoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for (i = 9; i>=1; i--) for (j = 2; j a[3]) YES swap(a, j-1, j); swap(a, 2, 3) }

  • A A E M N L E P Xvoid bubbles(itemType a[], int N) bubbles(a[], 9){ int i, j; for (i = N; i >= 1; i--) for (i = 9; i>=1; i--) for (j = 2; j a[4]) NO swap(a, j-1, j); }

  • A A E M N L E P Xvoid bubbles(itemType a[], int N) bubbles(a[], 9){

Recommended

View more >