1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kirza4 [7]
2 years ago
10

Dr. Watson has been kidnaped! Sherlock Holmes was contacted by the kidnapper for ransom. Moments later he received a message fro

m 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. 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. Design a dynamic programming algorithm which takes three input sequences X, Y, and Z, of lengths m, n, and p, respectively, and returns their longest common subsequence. For full marks your algorithm should run in (mnp) time. Note that 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.
Required:
Describe the set of subproblems that your dynamic programming algorithm will consider.
Computers and Technology
1 answer:
adelina 88 [10]2 years ago
8 0

Answer:

please mark me brainlist

Explanation:

This algorithm works for n number of strings in python3

Input:

83217

8213897

683147

Output:

837

from itertools import product

import pdb

import numpy as np

def neigh(index):

N = len(index)

for ri in product((0, -1), repeat=N):

if not all(i == 0 for i in ri):

yield tuple(i + i_rel for i, i_rel in zip(index, ri))

def longestCommonSubSequenceOfN(sqs):

numberOfSequences = len(sqs); # to know number of sequences

lengths = np.array([len(sequence) for sequence in sqs]); # to know length of each sequences placed in # array

incrLengths = lengths + 1; # here we are taking no .of sequences +1

lengths = tuple(lengths); # making lengths into tuple to make it mutable

inverseDistances = np.zeros(incrLengths);

ranges = [tuple(range(1, length+1)) for length in lengths[::-1]]; # finding ranges from 1 to each lengths

for tupleIndex in product(*ranges):

tupleIndex = tupleIndex[::-1];

neighborIndexes = list(neigh(tupleIndex)); # finding neighbours for each tupled index value and # store them in list

operationsWithMisMatch = np.array([]); # creating array which are miss matched

 

for neighborIndex in neighborIndexes:

operationsWithMisMatch = np.append(operationsWithMisMatch, inverseDistances[neighborIndex]);

#appending newly created array with operations miss match and inverseDistances

operationsWithMatch = np.copy(operationsWithMisMatch);

# copying newly generated missmatch indexs

operationsWithMatch[-1] = operationsWithMatch[-1] + 1;

# incrementing last indexed value

chars = [sqs[i][neighborIndexes[-1][i]] for i in range(numberOfSequences)];

# finding a string(chars) with neighbour indexes and checking with other sequences

if(all(elem == chars[0] for elem in chars)):

inverseDistances[tupleIndex] = max(operationsWithMatch);

else:

inverseDistances[tupleIndex] = max(operationsWithMisMatch);

 

subString = ""; # resulted string

mainTupleIndex = lengths; # copying lengths list to mainTupleIndex

while(all(ind > 0 for ind in mainTupleIndex)):

neighborsIndexes = list(neigh(mainTupleIndex));

#generating neighbour indexes with main tuple index in form of list

anyOperation = False;

for tupleIndex in neighborsIndexes:

current = inverseDistances[mainTupleIndex];

if(current == inverseDistances[tupleIndex]): # comparing indexes in main tuple index and inverse #distance tuple index

mainTupleIndex = tupleIndex;

anyOperation = True;

break;

if(not anyOperation): # if anyoperation is False then we are generating sunString

subString += str(sqs[0][mainTupleIndex[0] - 1]);

mainTupleIndex = neighborsIndexes[-1];

return subString[::-1]; # reversing resulted string

sequences = ["83217", "8213897", "683147"]

print(longestCommonSubSequenceOfN(sequences)); #837

You might be interested in
If I use the command right(90), which way will Tracy turn?<br> If correct I mark brainlist
Kaylis [27]

Answer: Right

Explanation: If you use the Command Right (90°), it makes sense that Tracy turns right 90°...

5 0
2 years ago
If your computer has a ________, someone else can gain access to it undetected.
irinina [24]
<span>If your computer has a rootkit, someone else can gain access to it undetected.
</span>The term rootkit denotes a set of software tools <span>typically malicious.
 The purpose of this software is to enable access to a computer or areas of its software that is not otherwise allowed.
</span><span>It is one of the most difficult types of malware to find and remove.</span>
3 0
3 years ago
A business wants to centralize its administrative tasks. At the same time, it wants the existing systems to manage and sustain t
qwelly [4]

Answer:

real-time analytics

Explanation:

Real time analytics is a type of data analysis that is done immediately the data for analysis is available. This can allow users to draw conclusion or acquire new insights swiftly and immediately the data enters their system. Businesses use real time analytics when there is a need to make and execute new decisions without hesitation.

A business that wants to centralize its administrative tasks and simultaneously wants the existing system to manage and sustain the growing amount of work in a capable manner would use real-time analytics.

7 0
3 years ago
What command would you issue from a command prompt to see a listing of the computers in your workgroup?
ololo11 [35]
<span>Net View is the command issue from a command prompt to see a listing of the computers in your workgroup.It will display the list of domains,computers resources which have been shared by the specified computer then it will list all computers currently in our domain.The syntax for net view using command prompt NET VIEW [\\computername [/CACHE] | [/ALL] | /DOMAIN[:domainname]].</span>
8 0
3 years ago
What are the steps for adding an action button to a slide? Choose the correct answers from the drop-down menus. 1. First, go to
Marysya12 [62]

Answer:

insert, illustrations, click and drag, slide show

Explanation:

i got it right

7 0
2 years ago
Read 2 more answers
Other questions:
  • I really need help please abari is writing a program which prompts a user for a value without a decimal. Which function should h
    8·1 answer
  • The item that is clicked in a JList can be retrieved using the _____ method of JList.
    8·1 answer
  • ​User documentation _____. Group of answer choices ​allows users to prepare overall documentation, such as process descriptions
    9·1 answer
  • Explain the use of keyboard shortcuts and key combinations. You are at the tenth page of a 20-page document. You need to make ch
    14·1 answer
  • The part of the computer that contains the brain or the Central Park nursing unit is also known as
    10·1 answer
  • Gary has to complete a form before enrolling into an online course. A few of the fields require Gary to respond with either a "Y
    7·2 answers
  • The theory of logic set the foundation for what aspect of computing today?
    11·1 answer
  • The right to make others do things is referred to as _________.
    14·2 answers
  • Make a list of five primary raw materials, for each one, indicate and industrial material that is created from it
    10·2 answers
  • What are the three main elements common to all radio ads?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!