Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started