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

Wrtite a JCL for sorting a file with start from 36 postion lenth 9 excluding a num eq to 98768. for 3 marks mainframe

0 Answers  


how we can call xml file in java file using Android platform?

2 Answers   TCS,


what is difference between c and C#

12 Answers   MCN Solutions,


I want to insert date in the form of yyyy-mm-dd... if any changes happen while inserting date format want to show error meg...any one can solve this..??

0 Answers  


what is the diffrence between software and hardware language?

0 Answers  






Number of null pointers in any binary tree

5 Answers   Infosys,


can anyone please tell me the procedure for the NIC personal interview as i have been selected for the post of scientist/technical assistant B

2 Answers   NIC,


For a binary tree with n nodes, How many nodes are there which has got both a parent and a child?

0 Answers  


Write a program to find factorial of a number using functions

0 Answers   Peerless,


Building Quotation engine program

5 Answers   Wipro,


what is delegate and delegation model give the real live example on delegate model

0 Answers   TCS,


major characteristics of software system

0 Answers  


Categories