TUGAS 1:menghitung Running time

TUGAS 1:menghitung Running time

Achmad Irwanto (2012420031)

Berikut adalah postingan tentang penghitungan algoritma utk mengetahui kecepatan Running time..

public static void main(String[] args) {
String[]Q ={"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[]W = {"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[] E = kode.toCharArray();
for (int i=0;i<E.length;i++){
for (int j=0;j<Q.length;j++){
if (String.valueOf(E[i]).equalsIgnoreCase(Q[j]))
System.out.println(W[j]);
}
}
System.out.println("");
}
}



//Perhitungan
String [] Q                                                                      1x
String [] W                                                                  1x
String kode                                                                     1x
char   [] E                                                                  nx
i = 0;                                                                              1x
i<E.length;                                                                 nx
i++;                                                                                nx
j=0;                                                                                1x
j<Q.length;                                                               n x n
j++;                                                                                n x n
String.valueOf(E[i]).equalsIgnoreCase(Q[j])             nx
System.out.print(W[j]);                                                n x n
System.out.print(“ ”);                                                       1x

6 + 4n + 3n2  kali   -->    T (n) = O (n2)



share this article to: Facebook Twitter Google+ Linkedin Technorati Digg
Posted by arek informatika, Published at 12.12 and have 0 komentar

Tidak ada komentar:

Posting Komentar