CSCI651 Algorithm Concepts Assignment: Algorithms and Data Structures Design, implement and analyze two algorithms to solve the longest common prefix (LCP)

CSCI651 Algorithm Concepts Assignment: Algorithms and Data Structures Design, implement and analyze two algorithms to solve the longest common prefix (LCP) and Longest common subsequence (LCS) problem using the naive brute force approach and divide and conquer approach. CSCI 651 Algorithm Concepts
Assignment 1
For this assignment, you will design, implement and analyze two algorithms to solve the longest
common prefix(LCP) and Longest common subsequence(LCS) problem using the naive brute force
approach and divide and conquer approach.
Longest Common Prefix (LCP)
Longest Common Subsequence (LCS)
Given the array of strings A,
Longest common subsequence (LCS) of two
you need to find the longest string S which is the strings is a substring with maximal length which
prefix of all the strings in the array.
is common to both the strings.
Example 1:
Input: [“flower”,”flow”,”flight”]
Output: “fl”
Example 2:
Input: [“dog”,”racecar”,”car”]
Output: “”
Example 1:
Input: [“aggtab”,”gxtxayb”]
Output: “gtab”
Example 2:
Input: [“racecar”,”fly”]
Output: “”
1. ?A. Write a function in any programming language of your choice for returning Longest Common
Subsequence(LCS) for two given sequences. Test your function on LCSin.txt contains 10 test cases
entries (each line contains one test case with 2 input strings with the output).
B?. Write the pseudocode for your algorithm. What is the asymptotic running time of your algorithm
with an explanation for your answer.
2. A. ?Design an algorithm and write pseudocode to find the longest common prefix string amongst an
array of strings using brute force approach.The idea is loop over the strings [S1…Sn], finding at each
iteration i the longest common prefix of strings LCP(S1…Si) When LCP(S1…Si) is an empty string,
the algorithm ends. Otherwise after n iterations, the algorithm returns LCP(S1…Sn).
B.? What is the asymptotic running time of your algorithm with an explanation for your answer.
3?. Design an algorithm to solve this problem using a divide and conquer strategy. To do this consider the
following facts. If you split the LCP(Si…Sj) problem into two subproblems (Si…Smid) and
LCP(Smid+1…Sj), where mid is {(i + j)/2}, We use their solutions lcpLeft and lcpRight to construct
the solution of the main problem LCP(Si…Sj). To accomplish this we compare one by one the
characters of lcpLeft and lcpRight till there is no character match. The found common prefix of lcpLeft
and lcpRight is the solution of the LCP(Si…Sj).
A?. Write the pseudocode for your algorithm
B?. What is the asymptotic running time of your algorithm. Provide an explanation for your answer.
4?. Using any programming language of your choice to implement the algorithms you designed in 2 and 3.
above. Use the attached LCPin.txt test file to show that your algorithms and implementations are correct.
The file has one test case per line (10 cases each with 20 entries). A line corresponding to the example
above would be: [“flower”,”flow”,”flight”],”fl” with the input array followed by the longest common
prefix. Include screenshots in your submission.
5. Experimental Analysis: For the experimental analysis you will plot running times as a function of input
size. Every programming language should provide access to a clock. Run algorithms constructed in 2
and 3 on input arrays of size 50 … 500 in increments of 50 (that is, you should have 10 data points for
each algorithm). To do this, generate random instances using a random string generator with some fixed
prefix. For each data point, you should take the average of a small number (say, 10) runs to smooth out
any noise. For example, for the first data point, you will do something like:
for i = 1:10
A = random array with 50*i entries
start clock
longestCommonPrefix(A)
pause clock
return elapsed time
Note that you should not include the time to generate the instance. Plot the running times as a function of
input size for each algorithm in a single plot. Provide screenshots of your algorithm generating the
results. Include the code that runs the experiments in your submission.
6?. Discuss your plot in 5. Do the theoretical and experimental running times agree?
7?. Compare the complexities of Longest Common Subsequence (LCS) and Longest Common Prefix (LCP)
constructed in the above questions. Provide valid explanation for your answer.
8. Provide real-world examples that can be modelled and solved as a Longest common prefix problem and
Longest Common Subsequence problem.
Submit a report along with all your implemented code, which should include a detailed readme file
(which should explain how to run the code) in separate files via Blackboard by the due date.
[“aacpmdbk”,”aawvjwmt”,”aajsvkvt”,”aajpjpxq”,”aanqliaq”,”aaqdfdhg”,”aandcxzo”,”aaqi
hltd”,”aaecsosq”,”aafghqph”,
“aaafavcds”,”aacdfsf”,”aaaaa”,”aacxzxczx”,”aarwer”,”aacccccc”,”aazzzz”,”aaxxx”,”aaf
ff”,”aabbv”],”aa”
[“abbvrxazbwv”,”abbbbfxfllbsdimmcc”,”abbptgyqcaz”,”abbcomcluii”,”abbbbokxrxjciipnsl
“,”ababbababa”,”abbabbaba”,”abab”,”abaaa”,”abbbbabbbaba”,
“abb”,”abcdsdddd”,”abfrfsr”,”abbfers”,”abbbbbbbbbbaaabaa”,”abghfgh”,”ab”,”abgggg”,”
abvdf”,”abbcxx”],”ab”
[“cfcfcfcf”,”cfre”,”cfg”,”cfdfdfdfdf”,”cdfdfsdfa”,”ccccc”,”cc”,”ccc”,”cdfd”,”crer”,
“cwew”,”cfas”,”cvbv”,”cnbnv”,”czxcsd”,”crew”,”chgf”,”cnv”,”cnm”,”dcdf”],””
[“foooff”,”fooooofooofoofoo”,”foooooooofoffooo”,”fooooo”,”fooofofofo”,”fooooofooo”,
“foooffofof”,”foooffffff”,”fooofofofo”,”fooooofooo”,
“foofoofffffooo”,”fooofoffoofoof”,”foofoooofoofff”,”fooo”,”fooooo”,”fooooffofffooo”
,”foooof”,”foooooo”,”fooffof”,”foooooood”],”foo”
[“meenneenene”,”meenmmenene”,”meenn”,”meennmmmn”,”meeneeen”,”meennnn”,”meemnme”,”me
enne”,”mee”,”meem”,
“meen”,”meee”,”meenee”,”meeneennem”,”menn”,”meenmnenm”,”meeeeee”,”meeenene”,”meneme
“,”men”],”me”
[“uxouxuxu”,”uxouooxxxttxuouo”,”uxouuu”,”uxooooo”,”uxoo”,”uxx”,”uxxtoxtttuxtoxto”,”
uxoxuoot”,”uxoxtttt”,”uxooot”,
“uxoxoxoxo”,”uxxxt”,”uxt”,”uxot”,”uxutuxxxtxtuuuxt”,”uxuuotootuooxott”,”uxooxxto”,”
uxuotuxx”,”uxoxo”,”uxuuut”],”ux”
[“iijiii”,”iijjjj”,”iijj”,”iijiiijijjjjljlii”,”iijijiijiji”,”iijiii”,”iijjjijllljjj
ljil”,”iijjllll”,”iijll”,”iijjijjjlilililll”,
“iijl”,”iijll”,”iillll”,”iijilljilji”,”iijljiji”,”iijldddd”,”iijjlllllliiii”,”iijjj
je”,”iijida”,”iij”],”ii”
[“zzzzzz”,”zzzzz”,”zzzzzz”,”zzzzz”,”zzzzzzzz”,”zzzzz”,”zzzzzzz”,”zzzzzzzzzzz”,”zzzz
“,”zzzzz”,
“zzzzzzzzz”,”zzzzz”,”zzz”,”zz”,”zzzzzzz”,”zzzzzzzzzz”,”zzzzzz”,”zzzzzzzzzzzzzzzz”,”
zzzzzzz”,”zzzzz”],”zz”
[“abbaababaaaab”,”abb”,”abbaba”,”abbababa”,”abbb”,”abbabaabbab”,”abbaaaaaa”,”abbaaa
“,”abbaaabbbbaab”,”abaaabababaaa”,
“abbbbb”,”abbabababbbbb”,”abbabbbaaaa”,”abbaaaaaaaa”,”abbbbab”,”abbaaaa”,”abbaabbbb
“,”abbaaa”,”abbaa”,”abba”],”ab”
[“eooeuuuouu”,”eoouooueeu”,”eoeouooeee”,”eoeoo”,”eoeee”,”eooo”,”eeooo”,”eooouuuu”,”
eoouuuuu”,”eee”
“eeouu”,”eeooo”,”eeooouuuu”,”eoouuueue”,”eeoo”,”eeooouu”,”eeeeeeo”,”eeeooooee”,”eeo
oeoeoeoe”,”eoeoe”],”e”
[“flower”,”flow”],”flow”
[“abcdxef”,”cldyef”],”cdef”
[“aggtab”,”gxtxayb”],”gtab”
[“abcdxef”,”cldyef”],”cdef”
[“thisisatest”,”testing”],”test”
[“car”,”fly”],””
[“xmjyauz”,”mzjawxu”],”mjau”
[“axxebdegaab”,”xgebaacbzzzg”],”xebaab”
[“acab”,”cab”],”cab”

Purchase answer to see full
attachment

Don't use plagiarized sources. Get Your Custom Essay on
CSCI651 Algorithm Concepts Assignment: Algorithms and Data Structures Design, implement and analyze two algorithms to solve the longest common prefix (LCP)
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT! To Get a 10% Discount Use Coupon Code FIRST39420
Order Essay
Calculator

Calculate the price of your paper

Total price:$26
Our features

We've got everything to become your favourite writing service

Need a better grade?
We've got you covered.

Order your paper