In Bioinformatics, a DNA sequence is made up of a
combination of 4 characters, namely “A,C,G,T”. A
subsequence of a given sequence of characters a0, a1, …an-
1, is any subset of the characters taken in order, of the
form ai0 , ai1 ,…..aik-1 where 0 ≤ i0 <i1….< ik-1 ≤ n-1.
For example in the sequence “A,C,G,T,G,T,C,A,A,A,A,T,C,G”,
we can have subsequences “A,G,T”, “A,C,A,A” and many more.
A subsequence is palindromic if it is the same whether read
left to right or right to left. For instance, the
sequence “A,C,G,T,G,T,C,A,A,A,A,T,C,G”, has many
palindromic subsequences, including “A,C,G,C,A”
and “A,A,A,A” (on the other hand, the subsequence “A,C,T”
is not palindromic). Devise an algorithm (using dynamic
programming) that takes a sequence of characters X[0 … n-1]
from the alphabet set (A,C,G,T) and returns the (length of
the) longest palindromic subsequence. Implement the
algorithm in an appropriate language.
Answer Posted / pragnesh
import java.io.*;
import java.util.*;
public class p3{
public static void main(String[] args) throws
FileNotFoundException{
Scanner inFile = new Scanner(new FileReader("words.txt"));
String s;
String temp, tempRev="";
while(inFile.hasNext()){
s=inFile.nextLine();
temp=s;
temp = temp.replace("?","");
temp = temp.replace(".","");
temp = temp.replace(",","");
temp = temp.replace(":","");
temp = temp.replace("\"","");
temp = temp.replace(" ","");
for(int x=temp.length()-1;x>=0;x--)
tempRev = tempRev + temp.charAt(x);
if(temp.equalsIgnoreCase(tempRev))
System.out.println(s + " is a palindrome");
else
System.out.println(s + " is not a palindrome");
tempRev="";
}
inFile.close();
}
}
maybe you could adapt that to c++
| Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
how many types of operating system are avaliable?
9.Difference between even and odd signals?explain with the diagram?
why we need to take u?
THERE ARE 4 SOURCE FILES WHICH CONTAINS SAME METADATA CREATE A TARGET THAT SHOULD DISPLAY THE FILE NAME ALONG WITH THE RECORD PLEASE SEND THE ANSWERFOR THIS QUESTION WITH MAPPING
Hello Experts, What is the difference between move and move corresponding exactly? please post me asap
You are given a dictionary of all valid words. You have the following 3 operations permitted on a word: delete a character, insert a character, replace a character. Now given two words - word1 and word2 - find the minimum number of steps required to convert word1 to word2. (one operation counts as 1 step.)
Can anyone send me NIC question papers alongwith answers on nidhi1485@yahoo.co.in? Urgently needed.. Thanks in advance
when will triggars the at new event in abap and web dybn pro?
5. Which of the following can you do with DB2 Express- C? Query databases with SQL Query databases with XML using XQuery and XPath Use SQL in Xquery and Xquery in SQL All of the above
what is the use of occurs 10 or (any number) in the internal table declaration with header line.
in cobol,wat is the difference in using 'set index in occurs clause' ....and 'occurs depending-on clause'
Hello...has anyone interviewed with Information Management Services(IMS)located in Silver Spring MD??If yes,what can you share about the programming test and the analytical test?
what are the differences between CONS, LIST, and APPEND
write the a cl program with the following specification A. Accept 2 parameters-date and date type B. if date type is J then convert date to *MDY format C. if date type is M convert date to *JUL format 4.send a program message with the value of converted date Please explain for each with coding?
what are all the validation we need to perform in data stage?