Program Insertion Sort dengan Java

Program Insertion Sort dengan Java

Berikut listing program Insertion Sort dengan Java yang menapilkan proses pengurutan dari awal sampai selesai. Selamat mencoba yaaa…..

import static java.lang.System.out;

public class ProsesISort{
     public static void main(String[]args){              
          system.out.println("t------------------------------------------");               
          system.out.println("t| Langkah-langkah sorting Insertion Sort |");               
          system.out.println("t| Misalkan ada Lima angka :9,7,1,2,5 |");               
          system.out.println("t------------------------------------------");               
          system.out.println("nBerikut Langkah-langkahnya : "); 

          int angka[] = {9,7,1,2,5};
          for(int i=0; i0 && temp{
                   angka[j]=angka[j-1];
               }
               angka[j] = temp;
               system. out.println("nLangkah ke-"+(i+1));
               system.out.println("t+---+---+---+---+---+"); 
               system.out.println("t| "+angka[0]+" | "+angka[1]+" | "+angka[2]+" | "+angka[3]+" |"+angka[4]+" |");
               system.out.println("t+---+---+---+---+---+");
          }
     } 
}
Share