Insertion Sort di Java

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package insertionsortnew;

/**
*
* @author KIREINA
*/
public class insertionSortNew {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int array[] = {4,5,1,8,6,2,7,20,12,24,14,17};
int a;
int b;

System.out.println(“Data acak :”);
for(int index=0; index<array.length; index++) {
System.out.print(array[index]+" ");
}
System.out.println("");

// sorting
for(a=1; a0 && array[b-1] >= temp) {
array[b] = array[b-1];
b–;
}
array[b] = temp;
}

System.out.println(“Setelah Sorting :”);
for(int index=0; index<array.length; index++) {
System.out.print(array[index] +" ");
}
System.out.println("");
}
}

2 pemikiran pada “Insertion Sort di Java

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google

You are commenting using your Google account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s