Question: Design a brute-force algorithm based on the given description to solve the stated problem and write its pseudocode. The Computational Problem: Assume you have two

Design a brute-force algorithm based on the given description to solve the stated problem
and write its pseudocode.
 Design a brute-force algorithm based on the given description to solve

The Computational Problem: Assume you have two sequences X and Y of the same length m>1, where each sequence contains integer values. The goal of this problem is to find a subsequence S which has the following properties: 1. The subsequence S is common to both X and Y. 2. The subsequence S length is maximum among any other common subsequences. 3. The subsequence S cannot be empty. 4. The values in subsequence S are consecutive values in X and Y. Brute-force algorithm: Generate all possible subsequences of X, and all subsequences of Y. Then, for each subsequence sx in X, and for each subsequence sy in Y, check if sx and sy are equal. If so, then compare its length with the maximum common subsequence found so far and keep the maximum length subsequence. Input Format Input consists of two 1-dimenional arrays of size m, where m>1 Output Format Output is: - n: length of the subsequence S - i : starting index in sequence X for the first element in S - j : starting index in sequence Y for the first element in S Example 1: X={2,4,6,8,10,12,14,16,18,20}Y={13,15,18,1,3,5,8,10,12,20} Longest common subsequence is S={8,10,12} with length 3 . n=3i=4j=7

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!