Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the following implementation of the longest common subsequence algorithm: /* * find the longest common subsequence between two strings. Note that * unlike substrings,

Given the following implementation of the longest common subsequence algorithm: /* * find the longest common subsequence between two strings. Note that * unlike substrings, subsequences are not required to occupy consecutive * positions within the original sequences. * @param x - the first string * @param y - the second string * @returns the longest subsequence * * example: GGCACCACG,ACGGCGGATACG => GGCAACG */ public static String lcs(String x, String y) { int m = x.length(), n = y.length(); int[][] opt = new int[m+1][n+1]; for (int i = m-1; i >= 0; i--) { for (int j = n-1; j >= 0; j--) { if (x.charAt(i) == y.charAt(j)) { opt[i][j] = opt[i+1][j+1] + 1; } else { opt[i][j] = Math.max(opt[i+1][j], opt[i][j+1]); } } } // Recover LCS itself. String lcs = ""; int i = 0, j = 0; while (i < m && j < n) { if (x.charAt(i) == y.charAt(j)) { lcs += x.charAt(i); i++; j++; } else if (opt[i+1][j] >= opt[i][j+1]) { i++; } else { j++; } 1

} return lcs; } Complete the following tasks: 1. Draw a control flow graph for the lcs method. Enumerate the nodes in the graph. 2. Label the control graph with defs and uses at the appropriate nodes. 3. Compute the all-def-use paths criteria for the graph. 4. Implement a set of JUnit tests that cover as many of the all-def-use paths (test requirements) as possible. 5. Reflecting on the JUnit test you have written in the previous task, are there any tests that you would have written if you only used your intuition and did not follow the all-def-use criteria. Are there any tests that you ended up writing that you would not have otherwise thought of? Turn in your code and associated graphs as an additional document in a format I can easily open (e.g. MS Word, PDF).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

0764549634, 9780764549632

More Books

Students also viewed these Databases questions

Question

8. Measure the effectiveness of the succession planning process.

Answered: 1 week ago