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…..

<br />
import static java.lang.System.out;</p>
<p>public class ProsesISort{<br />
     public static void main(String[]args){<br />
          system.out.println(&quot;t------------------------------------------&quot;);<br />
          system.out.println(&quot;t| Langkah-langkah sorting Insertion Sort |&quot;);<br />
          system.out.println(&quot;t| Misalkan ada Lima angka :9,7,1,2,5 |&quot;);<br />
          system.out.println(&quot;t------------------------------------------&quot;);<br />
          system.out.println(&quot;nBerikut Langkah-langkahnya : &quot;); </p>
<p>          int angka[] = {9,7,1,2,5};<br />
          for(int i=0; i0 &amp;amp;&amp;amp; temp{<br />
                   angka[j]=angka[j-1];<br />
               }<br />
               angka[j] = temp;<br />
               system. out.println(&quot;nLangkah ke-&quot;+(i+1));<br />
               system.out.println(&quot;t+---+---+---+---+---+&quot;);<br />
               system.out.println(&quot;t| &quot;+angka[0]+&quot; | &quot;+angka[1]+&quot; | &quot;+angka[2]+&quot; | &quot;+angka[3]+&quot; |&quot;+angka[4]+&quot; |&quot;);<br />
               system.out.println(&quot;t+---+---+---+---+---+&quot;);<br />
          }<br />
     }<br />
}<br />

Share