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 &#8804; i0 <i1….< ik-1 &#8804; 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.



In Bioinformatics, a DNA sequence is made up of a combination of 4 characters, namely “A,C,G,T..

Answer / 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

More Programming Languages AllOther Interview Questions

What is the merger sort principle and its time complexity.

0 Answers   Verifone,


kindly send interview materials

0 Answers   SoftSquare,


which one is the best practice using synchronization method or synchronization block

1 Answers   TCS,


Suppose we are doing 4 operations on database using service, first operation is successful but due to some reason remaining 3 operations are failed. I) is this transaction successful or not? ii) How can you give that error message to user?

0 Answers  


1.Mutating table

0 Answers  






Data Structure:  How many comparisons are necessary to find the largest and smallest of a set of n distinct elements?  

0 Answers   Student,


How to find the aerry size

1 Answers   Cap Gemini,


what is the extension of SPDS Dynamic cluster tables?

0 Answers   IBM,


Hi..Am done with my Masters recently..Am planning to learn TIBCO.. could anyone suggest me about how the job market will be and Is there any course necessary to learn prior to Tibco..i mean any prerequisite. I dnt have any knowledge on PL/SQL thats it... Plz suggest me in a best way...

0 Answers  


What is procedural oriented language language..? give some examples of this language....?

0 Answers  


What are the tasks performed by a Team Lead

0 Answers   Emphasis,


i need informatica certification dumps(S-powercenter 8 mapping designer)......plz fwd it to my mail id:gaya1989@yahoo.com

1 Answers  


Categories