Recursion Lab Longest Palindrome Subsequence (LPS) is a poster child for recursion and very hard to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Recursion Lab Longest Palindrome Subsequence (LPS) is a "poster child" for recursion and very hard to solve in any other way. In this lab you will create class named LPS and within that class you will write two methods: 1ps Length (String str) and lpsString (...) Given a string str, lps Length (String str) returns the length of the LPS in str lpsString (...) returns one LPS string You may assume that the initial given string str is not an empty string. Here are some examples. str zryxadavr aaxyz abcxcybza ATGCATCATTGACCA Lps length 5 Lps string radar 2 aa 7 10 abcxcba ACCATTACCA Notice that the sequence "zryxadavr" contains the palindrome subsequence "radar" within it: zryxadavr r ada r In fact, "radar", which has length 5, is the longest palindrome that can be found embedded in "zryxadavr". We say that "radar" is the longest palindromic subsequence (LPS) in the given string "zryxadavr". Example1 Input string: zryxadavr Output: Ips length = 5 Ips string = radar Example 2 Input string: ATGCATCATTGACCA Output: Ips length = 10 Ips string ACCATTACCA Submit you work in ONE Zip file and submit it in Canvas. Zip filename should be in format of FirstLast_Lab2.zip (ex. John Doe_Lab2.zip) Zip file should contain 4 files only: (1) LPS.java (2) LPSDemo.java (3) Output.docx (screenshot/copy program output and put in a word document) (4) Pseudo-code.docx (explain recursive logic in terms of pseudo-code) 2 Recursion Lab Longest Palindrome Subsequence (LPS) is a "poster child" for recursion and very hard to solve in any other way. In this lab you will create class named LPS and within that class you will write two methods: 1ps Length (String str) and lpsString (...) Given a string str, lps Length (String str) returns the length of the LPS in str lpsString (...) returns one LPS string You may assume that the initial given string str is not an empty string. Here are some examples. str zryxadavr aaxyz abcxcybza ATGCATCATTGACCA Lps length 5 Lps string radar 2 aa 7 10 abcxcba ACCATTACCA Notice that the sequence "zryxadavr" contains the palindrome subsequence "radar" within it: zryxadavr r ada r In fact, "radar", which has length 5, is the longest palindrome that can be found embedded in "zryxadavr". We say that "radar" is the longest palindromic subsequence (LPS) in the given string "zryxadavr". Example1 Input string: zryxadavr Output: Ips length = 5 Ips string = radar Example 2 Input string: ATGCATCATTGACCA Output: Ips length = 10 Ips string ACCATTACCA Submit you work in ONE Zip file and submit it in Canvas. Zip filename should be in format of FirstLast_Lab2.zip (ex. John Doe_Lab2.zip) Zip file should contain 4 files only: (1) LPS.java (2) LPSDemo.java (3) Output.docx (screenshot/copy program output and put in a word document) (4) Pseudo-code.docx (explain recursive logic in terms of pseudo-code) 2
Expert Answer:
Posted Date:
Students also viewed these programming questions
-
For a project that has a net investment of $ 1 , 3 5 0 , 0 0 0 and net cash flows of $ 4 0 0 0 , 0 0 0 for 5 years; Is the internal rate of return between ( 1 5 % and 1 2 % ) or ( 1 2 % and 8 % ) ....
-
The site http://virtualpiano.net features an online player piano. If you click on the Key Assist menu just above the piano keyboard, and then Keyboard Keys, you will see that each key is labelled...
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Solve each equation in Exercises. Round decimal answers to four decimal places. log 3 (x 2 + 17) - log3 (x + 5) = 1
-
In Example 7.9 on page 294, we conducted a simulation to check the plausibility of the central limit theorem. The variable under consideration there is household size, and the population consists of...
-
(a) Calculate the electronic partition function of a tellurium atom at (i) 298 K, (ii) 5000 K by direct summation using the following data: (b) What proportion of the Te atoms are in the ground term...
-
The nature of the resource demands generated via the workload model must be appropriate to the system or the component under study. Briefly explain.
-
A lease agreement between Mooney Leasing Company and Rode Company is described in E21-8. Instructions Refer to the data in E21-8 and do the following for the lessor. (a) Compute the amount of the...
-
Evaluate the formula n = zp (1-p) E when z = 1.935, p = 0.36, and E = 0.02. n = (Round up to the nearest whole number as needed.)
-
Let X~ Bin(50, 0.4) be a binomial random variable and Y~ Geo(0.4) be a geometric random variable. Assume that X and Y are independent. What is Var(4X+2Y) ? 69.6 3.75 None of them 24.6 17.4 53.4 36.6
-
Suppose a firm's demand curve is P = 100 - Q. Find MR when Q = 10. Please show work
-
A Treasury bond with maturity exactly 18 years and 5 months and coupon 5.0 percent trades at an yield to maturity (YTM) of 3.3 percent (BEY). What is the value of the bond (and, therefore, its dirty...
-
The sound level measured in a room by person watching a movie on a home theater system varies from 55 dB during a quiet part to 85 dB during a loud part. Approximately how many times louder is the...
-
Instructions Reflection Journal on Change Management Course Objectives: To critically reflect on the key concepts and principles learned in the change management course. To apply the knowledge...
-
Suppose you are viewing a diffraction pattern created by green laser light ( = 450 nm), through double slits that are 0.09 mm apart. The displacement between the bright spots is 2 cm. What is the...
-
Accounting On the package, it claims the pozole to be 100% organic, gluten free, contain no GMOs or animal products, and be made at facilities that only use clean energy. Pelosi is seeking Organic,...
-
If the amplifier indicated by the box input impedance of oo, which of the following statements are true ? has an open loop gain as well as Feedback factor (\beta = 1/ R_1\) The feedback is voltage...
-
Which of the following functional capabilities in generalized audit software are auditors most likely to use to examine whether the entities that the data purports to represent do, in fact, exist? a....
-
During the feasibility analysis and planning stage of a generalized audit software application, which of the following factors is least likely to affect the decision on whether to proceed with the...
-
Which of the following is most likely to be a reason for wanting to transfer a file from a mainframe computer to a microcomputer on which generalized audit software resides? a. Auditors can process...
Study smarter with the SolutionInn App