Professional Documents
Culture Documents
import java.util.Random;
public class RandomDNA {
public String generateDNAstring(int n) {
String lDNA = "";
Random lRandomizer = new Random();
// place your Lab 01 implementation here
return lDNA;
}
// a test client
public static void main(String[] argv) {
RandomDNA myRandomDNA = new RandomDNA();
String myDNAstring = "";
for (int i = 10; i<=1000; i = i * 10) {
System.out.println("");
myDNAstring = myRandomDNA.generateDNAstring(i);
System.out.println("a DNA sequence " + i + " characters long: "
myDNAstring);
}
System.out.print(myDNAstring);
}
} // end of class RandomDNA
2. For this Problem Set task, you need to expand on the above
code, so that it generates two random DNA sequences (of the
same length) and computes their distance (their Hamming
distance, defined below).
3. for C343 purposes, the Hamming distance between two strings
of equal length is defined as:
the number of positions at which the corresponding symbols
are different;
for example, the Hamming distance between "ATC" and "ATG"
is 1.
a = b + c;
d = a + e;
2
sum = 0;
for (i=0; i<3; i++)
for (j=0; j<n; j+
+)
sum++;
sum=0;
for (i=0; i<n*n; i++)
sum++;
sum = 0;
for (i=1; i<=n; i++)
for (j=1; j<=n;
j*=2)
sum++;
sum = 0;
for (i=1; i<=n; i*=2)
for (j=1; j<=n; j+
+)
sum++;
D. Asymptotic Complexity
[25 points]
1. Arrange the following expressions by growth rate, from slowest
to fastest:
4n2
log3n
n!
3n
20 n
2
log2n
n2/3
2. Using the definitions of Big-O, find the upper bound for the
following expressions:
c1 n
c2 n3 + c3
c4 n log2n + c5 n
c6 2n + c7 n6