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

Given n red balls and m blue balls and some containers, how would you distribute those balls among the containers such that the probability of picking a red ball is maximized, assuming that the user randomly chooses a container and then randomly picks a ball from that.

0 Answers   Amazon,


How Many versions are there in crystal reports

2 Answers   Wipro,


what is the difference between a looping statement and a decision statement

4 Answers  


A string of charaters were given. Find the highest occurance of a character and display that character. eg.: INPUT: AEGBCNAVNEETGUPTAEDAGPE

7 Answers   Nagarro,


what is the BAM? where we can use it in BizTalk server?

0 Answers  






3 members in a pf.how we read 3 members without using ovrdbf.using rg pgms....

0 Answers   CTS,


ho&#65367;&#12288;&#65364;o check single or double byte in struts

0 Answers  


Need guidewire related Documents(Interview Question/Tips/Best Practice/Dumps)

0 Answers  


what is dynamic polymorphism?

2 Answers   Satyam,


hi i m deepak my shedule for NIC pi is 17 Apr please contact me if anybody has interview on same day or give me some idea who have faced

0 Answers  


what is the use MDM(Master Data Management)and meaning

0 Answers  


what is difference between scripts, smartforms and adobe forms

5 Answers  


Categories