Answered step by step
Verified Expert Solution
Question
1 Approved Answer
American singer Taylor Swift started doing musical theaters at the age of nine. Before that she used to attend the Wyndcroft School in the
American singer Taylor Swift started doing musical theaters at the age of nine. Before that she used to attend the Wyndcroft School in the USA. Due to her undying passion in music, her father enrolled little Taylor in a guitar course in the school. The tutor there taught Taylor how to play the major and minor scales of the guitar. After two months of lessons, Taylor needed to pass a test with 50% accuracy to get the course completion certificate from the school. The test was to play all the notes of the C major scale in the given order "C D EFGABC". D E A B -2 The results from the test measured the accuracy percentage of the longest common sequence of notes played by the students when compared to the given sequence of C DEFGABC. For example, when Taylor gave this test, she got an accuracy of 75% as her played notes were CEFDABGAC" When asked, the teachers explained their accuracy measurement formula as below: Accuracy = (Length of Longest Common Played Notes Total Length of Given Sequence) x 100 For little Taylor, her longest common played notes were in the sequence of "CEFABC". So the accuracy measured was 75% as her length of longest common played notes is 6 and the total length of the given sequence is 8. Since there are numerous students in the course, the school decided to develop an algorithm that will find the accuracy output of the students along with their longest common played notes and also determine whether they passed or failed. Your job is to help the school build the algorithm. SAMPLE INPUT: //given note sequence in test by school CEFDABGAC /played note sequence by a student CDEFGABC SAMPLE OUTPUT: CEFABC 75% PASSED Problem 2: In a small version of the FRIENDS world, there exists only 10 words with which people communicate. The words are indexed for simplicity using the alphabets given below: M: monkeys B: because W: wearing O: of C: coats E: evolution A: are R: results D: doctors P: eruption At a turn of events, two friends named Ross and Chandler got into a debate when they blamed each other for copying their joke. So they invited Monica over to help them decide whether Chandler copied the joke from Ross or not. Ross's Joke: monkeys wearing coats are doctors because of evolution Chandler's Joke: doctors monkeys wearing coats are results of eruption So to make the decision, Monica thought of applying "Longest Common Sequence" algorithm to both the jokes and tell Chandler how many consecutive words he had copied from Ross. She found the LCS to contain the words "monkeys, wearing, coats, are, of". Your job is to help Monica make the program to get the LCS word count and also print the sequence. (Hint: You will need to first store the index table given above.) SAMPLE INPUT: M WCADBOE DM W CAROP SAMPLE OUTPUT: monkeys wearing coats are of
Step by Step Solution
★★★★★
3.53 Rating (153 Votes )
There are 3 Steps involved in it
Step: 1
1 LCS or the Longest Common Subsequence is fairly known problem which can be solved using the concepts of Dynamic Programming in a 2D Matrix Here is a ...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