Question: how do I write a code un java that takes two sequences X and Y from the user and their length (the two sequences must
how do I write a code un java that takes two sequences X and Y from the user and their length (the two sequences must be of the same length) and finds the longest common subsequence S (elemnts in S must be consecutive (one after the other in the sequence)) prints its elements and the start index of S in both X and Y, and the length.
The runtime (time complexity) of the code must be n^2 or less.
Example:
Input:
X = {1, 4, 7, 2, 3, 5, 8, 9}
Y = {2, 3, 5, 8, 9, 7, 12, 1}
length = 8
Output:
S = {3, 5, 8, 9}
length = 4
start index in X = 4
start index in Y = 1
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
