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

A palindrome is a string that reads the same backwards and forwards. A complemen

ID: 3772550 • Letter: A

Question

A palindrome is a string that reads the same backwards and forwards. A complemented palindrome is one that when read backwards is the complement of the string reading forwards (the pairs A-T and G-C are considered complements). A maximal palindrome is one that is not contained in any other. For example, in the string "ATATGAGGAGGCCT" the substrings “AGGCCT” are maximal complemented palindromes.

(a) Write algorithms that determine all maximal palindromes and complemented palindromes for a given input string.

(b) What are the running times of your algorithms?

(c) Implement and test your algorithm on a DNA sequence.

Explanation / Answer

(a)

Function longest_Palindrome(strIn)
For lngCnt1 = Len(strIn) To 2 Step -1
lngCnt = lngCnt1 2
strPal = vbNullString
For lngCnt2 = lngCnt To 1 Step -1
strPal = strPal & "(" & lngCnt2 & ")"
Next
If lngCnt1 Mod 2 = 1 Then strPal = "(.)" & strPal

Set objRegex = CreateObject("vbscript.regexp")
    With objRegex
        .Pattern = Replace(Space(lngCnt), Chr(32), "(.)") & strPal
        If .Test(strIn) Then
            Set objRegM = .Execute(strIn)
            Palindrome = objRegM(0)
            Exit For
        End If
    End With
Next
End Function

(b) k if this longest matching substring is actually a palindrome which has the running time of O(n^3).

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