Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You should provide a 'Dynamic Programming' algorithm to solve this problem. Dr. Watson has been kidnaped! Sherlock Holmes was contacted by the kidnapper for

imageimageimage

You should provide a 'Dynamic Programming' algorithm to solve this problem. Dr. Watson has been kidnaped! Sherlock Holmes was contacted by the kidnapper for ransom. Moments later he received a message from Dr. Watson's phone. The message contained three random strings. Sherlock being Sherlock, was able to deduce immediately that Dr. Watson was trying to give a hint about his location. He figured out that the longest common subsequence between the 3 words is the location. But since it was too easy for him, he got bored and asked you to find out what the actual location is. Your task is to find the longest common subsequence from the 3 given strings before it is too late. Definitions: Subsequence - A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements. For instance, given a sequence "drew"; "d", "w", "de", "drw", "drew" are all examples of valid subsequences (there are also others), while "er", "wdre" are not. Note: W is a common subsequence of X, Y, and Z if and only if W is a subsequence of X, W is a subsequence of Y and W is a subsequence of Z. If a common subsequence does not exist, return "Does not exist" (without quotes) Your goal is to find the longest common subsequence, not just any common subsequence. Input Format Three lines, each containing a string. Note: Each string only contains lowercase English alphabet letters (i.e. a, b, ..., y, z). Constraints 1 1 import java.io.*; 2 import java.util.*; 3 4 public class Solution { Java 8 * XX 5 6- public static void main(String[] args) { 7 /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ 8 } 9}

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_2

Step: 3

blur-text-image_3

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

Introduction To Management Science A Modeling And Cases Studies Approach With Spreadsheets

Authors: Frederick S. Hillier, Mark S. Hillier

5th Edition

978-0077825560, 78024064, 9780077498948, 007782556X, 77498941, 978-0078024061

More Books

Students also viewed these Programming questions

Question

What is conservation? Preservation? How do they differ?

Answered: 1 week ago