Menghitung Running time - by Rian Dhewantara. Berikut ini adalah tugas 1 mengenai cara untuk menghitung running time sebuah program. Langsung saja saya contohkan dengan codingan di bawah ini.
package rahasia;
import javax.swing.JOptionPane;
/**
*
* @author Dhewan
*/
public class Rahasia {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String [] aa = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n",
"o","p","q","r","s","t","u","v","w","x","y","z"," "};
String [] bb = {"10","20","30","40","50","60","70","80","90","00","11",
"21","31","41","51","61","71","81","91","01","12","22",
"32","42","52","62","72"};
String kode =JOptionPane.showInputDialog(null,"masukkan sandi anda");
char[] c = kode.toCharArray();
for (int i=0;i<c.length;i++){
for (int j=0;j<aa.length;j++){
if (String.valueOf(c[i]).equalsIgnoreCase(aa[j]))
//equels
System.out.print(bb[j]);
}
}
System.out.println("");
}
}
RUNNING TIME
String [] aa // sesuai dg jumla array 27 x
String [] bb // sesuai dg jumla array 27 x
String kode = JOptionPane.showInputDialog(null, "Masukkan sandi anda"); n x
int i = 0; 1 x
i < c.length; n x
i++ n x
int j = 0; 1 x
j < aa.length; n x n
j++ n x n
if(String.valueOf(c[i]).equalsIgnoreCase(aa[j])) n x n +
56 + 3n + 3n2 kali = T(n) = O ( n3 )
Nama : Mochammad Rian Dhewantara
Nim : 2012420093
Fakultas : Teknik Informatika
UNITOMO
Posted by 21.28 and have
0
komentar
, Published at
Tidak ada komentar:
Posting Komentar