There is an unknown DNA sequence U about which you would like to find some infor
ID: 3596362 • Letter: T
Question
There is an unknown DNA sequence U about which you would like to find some information. You are given a set S of n strings, and each string has length exactly k such that S is the set of all 2 k-length substrings of U. Now your goal is to construct a set T such that T is the set of all 2k-length substrings of U. Note that U is not given as input. Input is S: A set of
k-length substrings of U and output is T—set of all 2k-length substrings of U.
WarWithArray
This class will contain a method to return T. This class uses array to store S. You must not use any other data structure to store S. This class will have following constructor and method. WarWithArray(String[] s, int k ). s is the set of all k-length substrings of U. compute2k(). This method returns an arraylist of 2k-length strings which is the set of all 2k-length substrings of U. Return type of this method must be ArrayList.
Explanation / Answer
class WarWithArray{
private String[] data;
private int size;
public WarWithArray(String[] s,int k){
data = s;
size = k;
}
ArrayList<String> compute2k(){
ArrayList<String> list = new ArrayList<String>()
for (int i = 0; i<data.length; i++){
for(j=0;j<data.length; j++){
if (i != j)
list.add(data[i] + data[j]);
}
}
return list;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.