Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Sortierer4{
- //static void insertionSort (int[] a){
- public static void insertionSort (int[] a)
- {
- int i = 0;
- int j = 0;
- int key = 0;
- for (j = 2; j < a.length; j++)
- {
- key = a[j];
- i = j- 1;
- while ((i > 0) && (a[i] > key))
- {
- a[i+1] = a[i];
- i = i - 1;
- }
- a[i + 1] = key;
- }
- }
- static void bubbleSort (int[] a)
- {
- boolean vertauscht = true;
- int h = 0;
- int n= a.length-1;
- while (vertauscht & n>=1)
- {
- vertauscht = false;
- for (int i=0; i<n; i++)
- {
- if (a[i] > a[i+1])
- {
- h = a[i];
- a[i] = a[i+1];
- a[i+1] = h;
- vertauscht = true;
- }
- }
- n = n-1;
- }
- }
- }
Add Comment
Please, Sign In to add comment