Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given sequence v and w, describe an efficient algorithm that will determine if v

ID: 3761271 • Letter: G

Question

Given sequence v and w, describe an efficient algorithm that will determine if v could be an infected version of w. Implement this algorithm in java or preffered language.

A virus infects a bacterium, and modifies a replication process in the bacterium by inserting at every

A, a poly A of length 1 to 5.

at every C, a poly C of length 1 to 10.

at every G, a poly G of arbitrary length 1.

at every T, a poly T of arbitrary length 1.

No gaps or other insertions are allowed in the virally modified DNA. For example, the sequence

AAATAAAGGGGCCCCCTTTTTTTCC is an infected version of

ATAGCTC

Explanation / Answer

working java code

compiled on ideone:

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
   public static void checkDNA(final String dna) {
String outputDNA = "";
for (int i = 0; i < dna.length(); i++) {
int count = 0;
final char currentChar = dna.charAt(i);
for (int j = 0; j < i; j++) {
   count=0;
if (currentChar == dna.charAt(j)) {
++count;
}
}

if (!(count > 0))
outputDNA = outputDNA + currentChar;
}
System.out.println(outputDNA);
}
  
   public static void main (String[] args) throws java.lang.Exception
   {
       checkDNA("AAATAAAGGGGCCCCCTTTTTTTCC");
   }
}

Output:

ATAGCTC

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote