Write a recursive method called lengthOfLongestSubsequence(a, b) that calculates the length of the longest common subsequence (lcs) of two strings. For example, given the two strings aaacommonbbb and xxxcommonzzz the lcs is common which is 6 characters long so your function would return 6. The length of the lcs of two strings a

Answers

Answer 1

Answer:

Explanation:

The following code is written in Java and creates the recursive function to find the longest common substring as requested.

 static int lengthOfLongestSubsequence(String X, String Y) {

       int m = X.length();

       int n = Y.length();

       if (m == 0 || n == 0) {

           return 0;

       }

       if (X.charAt(m - 1) == Y.charAt(n - 1)) {

           return 1 + lengthOfLongestSubsequence(X, Y);

       } else {

           return Math.max(lengthOfLongestSubsequence(X, Y),

                   lengthOfLongestSubsequence(X, Y));

       }

   }


Related Questions

Write a function named printPattern that takes three arguments: a character and two integers. The character is to be printed. The first integer specifies the number of times that the character is to be printed on a line (repetitions), and the second integer specifies the number of lines that are to be printed. Also, your function must return an integer indicating the number of lines multiplied by the number of repetitions. Write a program that makes use of this function. That is in the main function you must read the inputs from the user (the character, and the two integers) and then call your function to do the printing.

Answers

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

    Scanner input = new Scanner(System.in);

    char c;

    int n1, n2;

   

 System.out.print("Enter the character: ");

 c = input.next().charAt(0);

 System.out.print("Enter the number of times that the character is to be printed on a line: ");

 n1 = input.nextInt();

 System.out.print("Enter the number of lines that are to be printed: ");

 n2 = input.nextInt();

 

 printPattern(c, n1, n2);

}

public static int printPattern(char c, int n1, int n2){

    for (int i=0; i<n2; i++){

        for (int j=0; j<n1; j++){

            System.out.print(c);

        }

        System.out.println();

    }

    return n1 * n2;

}

}

Explanation:

*The code is in Java.

Create a function named printPattern that takes one character c, and two integers n1, n2 as parameters

Inside the function:

Create a nested for loop. Since n2 represents the number of lines, the outer loop needs to iterate n2 times. Since n1 represents the number of times that the character is to be printed, the inner loop iterates n1 times. Inside the inner loop, print the c. Also, to have a new line after the character is printed n1 times on a line, we need to write a print statement after the inner loop.

Return the n1 * n2

Inside the main:

Declare the variables

Ask the user to enter the values for c, n1 and n2

Call the function with these values

# 1) Complete the function to return the result of the conversion
def convert_distance(miles):
km = miles * 1.6 # approximately 1.6 km in 1 mile

my_trip_miles = 55

# 2) Convert my_trip_miles to kilometers by calling the function above
my_trip_km = ___

# 3) Fill in the blank to print the result of the conversion
print("The distance in kilometers is " + ___)

# 4) Calculate the round-trip in kilometers by doubling the result,
# and fill in the blank to print the result
print("The round-trip in kilometers is " + ___)

Answers

Answer:

See explanation

Explanation:

Replace the ____ with the expressions in bold and italics

1)          return km

 

return km returns the result of the computation

2)  = convert_distance(my_trip_miles)

convert_distance(my_trip_miles) calls the function and passes my_trip_miles to the function

3)  + str(my_trip_km)

The above statement prints the returned value

4)  +str(my_trip_km * 2)

The above statement prints the returned value multiplied by 2

The microprogram counter (MPC) contains the address of the next microcode statement for the Mic1 emulator to execute. The MPC value is either the next sequential microcode instruction in the control store (PROM), or a microcode instruction in the control store pointed to by the ADDR bits in the current executing microinstruction. What part of the current executing microcode instruction determines the value placed in the MPC

Answers

Answer:

MAR bit

Explanation:

The MPC computers area set of software and hardware standards that was developed by the consortium of computer firms which is led by Microsoft. It contains the address of a next microcode for the Mic1 emulator foe execution.

The part of the executing microcode instruction that determines the value which is placed in the MOC is the MAR bit. The MAR is the memory address register in the CPU which stores the memory address or such addresses to which some data will be sent and also stored.

A disk has 4000 cylinders, each with 8 tracks of 512 blocks. A seek takes 1 msec per cylinder moved. If no attempt is made to put the blocks of a file close to each other, two blocks that are logically consecutive (i.e. follow one another in the file) will require an average seek, which takes 5 msec. If, however, the operating system makes an attempt to cluster related blocks, the mean interblock distance can be reduced to 2 cylinders and the seek time reduced to 100 microsec. How long does it take to read a 100 block file in both cases, if the rotational latency is 10 msec and the transfer time is 20 microsec per block

Answers

Answer:

The answer is below

Explanation:

a)

If the blocks of a file are not put together, that is for nonadjacent block of files to each other, the time (t) taken to read a 100 block file is:

t = (average seek + rotational latency + transfer time) * 100 block

Average seek = 5 msec, rotational latency = 10 msec and transfer time = 20 microsec = 0.02 msec

t = (5 + 10 + 0.02) * 100 = 1502 msec

b)

If the blocks of a file are put together, that is for adjacent block of files to each other, the time (t) taken to read a 100 block file is:

t = (seek time * mean interblock distance + rotational latency + transfer time) * 100 block

seek time = 100 microsec = 0.1 msec, rotational latency = 10 msec and transfer time = 20 microsec = 0.02 msec, mean interblock distance = 2 cylinders

t = (0.1*2 + 10 + 0.02) * 100 = 1022 msec

Define and use in your program the following functions to make your code more modular: convert_str_to_numeric_list - takes an input string, splits it into tokens, and returns the tokens stored in a list only if all tokens were numeric; otherwise, returns an empty list. get_avg - if the input list is not empty and stores only numerical values, returns the average value of the elements; otherwise, returns None. get_min - if the input list is not empty and stores only numerical values, returns the minimum value in the list; otherwise, returns None. get_max - if the input list is not empty and stores only numerical values, returns the maximum value in the list; otherwise, returns None.

Answers

Answer:

In Python:

def convert_str_to_numeric_list(teststr):

   nums = []

   res = teststr.split()

   for x in res:

       if x.isdecimal():

           nums.append(int(x))

       else:

           nums = []

           break;

   return nums

def get_avg(mylist):

   if not len(mylist) == 0:

       total = 0

       for i in mylist:

           total+=i

       ave = total/len(mylist)

   else:

       ave = "None"

   return ave

def get_min(mylist):

   if not len(mylist) == 0:

       minm = min(mylist)

   else:

       minm = "None"

   return minm

def get_max(mylist):

   if not len(mylist) == 0:

       maxm = max(mylist)

   else:

       maxm = "None"

   return maxm

mystr = input("Enter a string: ")

mylist = convert_str_to_numeric_list(mystr)

print("List: "+str(mylist))

print("Average: "+str(get_avg(mylist)))

print("Minimum: "+str(get_min(mylist)))

print("Maximum: "+str(get_max(mylist)))

Explanation:

See attachment for complete program where I use comment for line by line explanation

What techniques overcome resistance and improve the credibility of a product? Check all that apply.
Including performance tests, polls, or awards
Listing names of satisfied users
Sending unwanted merchandise
Using a celebrity name without authorization

Answers

Answer: Including performance tests, polls, or awards.

Listing names of satisfied users

Explanation:

For every business, it is important to build ones credibility as this is vital on keeping ones customers and clients. A credible organization is trusted and respected.

The techniques that can be used to overcome resistance and improve the credibility of a product include having performance tests, polls, or awards and also listing the names of satisfied users.

Sending unwanted merchandise and also using a celebrity name without authorization is bad for one's business as it will have a negative effect on the business credibility.

Open excel program then use the (IF) function to fill the column of (Expensive/Cheap) then save your

I need help in this computer homework send me it as excel

Answers

Answer:

(7,6)12>34=Mc²

Explanation:

AB

MA

B

F

с

AAB=BC,AM=MC

BM IAC , EF I BC

What is the full form of 'Rom

Answers

Answer:

Read-only memory

Explanation:

Read-only memory is a type of non-volatile memory used in computers and other electronic devices. Data stored in ROM cannot be electronically modified after the manufacture of the memory device.

discuss the term business information SYSTEMS ​

Answers

Answer:

Business information systems provide information that organizations use to manage themselves efficiently and effectively, typically using computer systems and technology. Primary components of business information systems include hardware, software, data, procedures (design, development, and documentation) and people.

Explanation:

Hope It Help you

__________ type of storage is very popular to store music, video and computer programs.
i am doing my homework plzz fast​

Answers

Answer:

Optical storage devices.

Explanation:

Optical storage device are those devices that read and store data using laser. To store data in optical storage devices low-power laser beams are used. It is a type of storage that stores data in an optical readability medium.

Examples of the optical storage device includes Compact disc (CD) and DVD.

The optical storage device is popular in storing data of music, videos, and computer program. Therefore, the optical storage device is the correct  answer.

All operations used to construct algorithms belong to one of three categories: sequential, conditional, or iterative. Below is a list of steps from a variety of algorithms. Determine which category to which each of the steps belong (sequential, conditional, or iterative). If the value of test_grade is between 90 and 100, assign a letter grade of A.
Prompt the user for a number, get number from user
Sequential Repeat steps 3-5 until count = 10
If divisor = 0, print error_message
Complete step 1, complete step 2, complete step 3

Answers

Answer:

Answered

Explanation:

1) Conditional category because it uses an IF statement: If value of test grade is between 90-100 assign A.

2) Sequential category: Prompt user for number and get number from user.

3) Iterative category because it is looping: Repeat steps 3-5 until count equals 10.

4)Conditional category: If divisor equals zero print error.

5) Sequential category.

Write a method, public static int insertSort(ArrayList list), which implements a insertion sort on the ArrayList of Integer objects list. In addition your insertSort method should return an int which represents a statement execution count recording how many times two elements from the ArrayList are compared. For example, if the parameter list prints as [3, 7, 2, 9, 1, 7] before a call to insertSort, it should print as [1, 2, 3, 7, 7, 9] after the method call. This call should return the value 10 since 10 values need to be compared to implement an insertion sort on this array.

Answers

Answer:

Here is the basics of insertionSort performed on an array of integers, this should get you started:

/**

* The insertionSort method performs an insertion sort on an int array. The

* array is sorted in ascending order.

*

* param array The array to sort.

*/

public static void insertionSort(int[] array) {

int unsortedValue;

int scan;

for (int index = 1; index < array.length; index++) {

unsortedValue = array[index];

scan = index;

while (scan > 0 && array[scan - 1] > unsortedValue) {

array[scan] = array[scan - 1];

scan--;

}

array[scan] = unsortedValue;

}

}

The Payroll Department keeps a list of employee information for each pay period in a text file. The format of each line of the file is the following: Write a program that inputs a filename from the user and prints to the terminal a report of the wages paid to the employees for the given period. The report should be in tabular forma

Answers

Answer:

In Python:

fname = input("Filename: ")

a_file = open(fname)

lines = a_file.readlines()

print("Name\t\tHours\t\tTotal Pay")

for line in lines:

eachline = line.rstrip(" ")

for cont in eachline:

 print(cont,end="\t")

print()

Explanation:

This prompts the user for file name

fname = input("Filename: ")

This opens the file

a_file = open(fname)

This reads the lines of the file

lines = a_file.readlines()

This prints the header of the report

print("Name\t\tHours\t\tTotal Pay")

This iterates through the content of each line

for line in lines:

This splits each line into tokens

eachline = line.rstrip(" ")

This iterates through the token and print the content of the file

for cont in eachline:

 print(cont,end="\t")

print()

why is an increase in tax rate not necessarily increase government revenue​

Answers

Answer:

An increase in tax rate raises more revenue than is lost to offsetting worker and investor behavior

Explanation:

Increasing rates beyond T* however would cause people not to work as much or not at all, thereby reducing total tax revenue

Computer programming

Answers

Here is the answer for the question

what is secondary memory?

Answers

Answer:

Secondary memory refers to storage devices, such as hard drives and solid state drives. It may also refer to removable storage media, such as USB flash drives, CDs, and DVDs. ... Additionally, secondary memory is non-volatile, meaning it retains its data with or without electrical power.

Which of the following is step two of the Five-Step Worksheet Creation Process?

Answers

Answer:

Add Labels.

As far as i remember.

Explanation:

Hope i helped, brainliest would be appreciated.

Have a great day!

   ~Aadi x

Add Labels is step two of the Five-Step Worksheet Creation Process. It helps in inserting the data and values in the worksheet.

What is label worksheet in Excel?

A label in a spreadsheet application like Microsoft Excel is text that offers information in the rows or columns around it. 3. Any writing placed above a part of a chart that provides extra details about the value of the chart is referred to as a label.

Thus, it is Add Labels

For more details about label worksheet in Excel, click here:

https://brainly.com/question/14719484

#SPJ2

Lists and Procedures Pseudocode Practice For each situation, provide a pseudocoded algorithm that would accomplish the task. Make sure to indent where appropriate. Situation A Write a program that: Takes the list lotsOfNumbers and uses a loop to find the sum of all of the odd numbers in the list (hint: use Mod). Displays the sum. Situation B Write a procedure that takes

Answers

Answer:

The pseudocoded algorithm is as follows:

Procedure sumOdd(lotsOfNumbers):

    oddSum = 0

    len = length(lotsOfNumbers)

    for i = 0 to len - 1

         if lotsOfNumbers[i] Mod 2 != 0:

              OddSum = OddSum + lotsOfNumbers[i]

Print(OddSum)

Explanation:

This defines the procedure

Procedure sumOdd(lotsOfNumbers):

This initializes the oddSum to 0

    oddSum = 0

This calculates the length of the list

    len = length(lotsOfNumbers)

This iterates through the list

    for i = 0 to len-1

This checks if current list item is odd

         if lotsOfNumbers[i] Mod 2 != 0:

If yes, the number is added to OddSum

              OddSum = OddSum + lotsOfNumbers[i]

This prints the calculated sum

Print(OddSum)

Write a SELECT statement that returns these columns from the Orders table: The CardNumber column The length of the CardNumber column The last four digits of the CardNumber columnWhen you get that working right, add the column that follows to the result set. This is more difficult because the column requires the use of functions within functions. A column that displays the last four digits of the CardNumber column in this format: XXXX-XXXX-XXXX-1234. In other words, use Xs for the first 12 digits of the card number and actual numbers for the last four digits of the number.selectCardNumber,len(CardNumber) as CardNumberLegnth,right(CardNumber, 4) as LastFourDigits,'XXXX-XXXX-XXXX-' + right(CardNumber, 4) as FormattedNumberfrom Orders

Answers

Answer:

SELECT

CardNumber,

len(CardNumber) as CardNumberLength,

right(CardNumber, 4) as LastFourDigits,

'XXXX-XXXX-XXXX-' + right(CardNumber, 4) as FormattedNumber

from Orders

Explanation:

The question you posted contains the answer (See answer section). So, I will only help in providing an explanation

Given

Table name: Orders

Records to select: CardNumber, length of CardNumber, last 4 digits of CardNumber

From the question, we understand that the last four digits should display the first 12 digits as X while the last 4 digits are displayed.

So, the solution is as follows:

SELECT ----> This implies that the query is to perform a select operation

CardNumber, ---> This represents a column to read

len(CardNumber) as CardNumberLength, -----> len(CardNumber) means that the length of card number is to be calculated.

as CardNumberLength implies that an CardNumberLength is used as an alias to represent the calculated length

right(CardNumber, 4) as LastFourDigits, --> This reads the 4 rightmost digit of column CardNumber

'XXXX-XXXX-XXXX-' + right(CardNumber, 4) as FormattedNumber --> This concatenates the prefix XXXX-XXXX-XXXX to the 4 rightmost digit of column CardNumber

as FormattedNumber implies that an FormattedNumber is used as an alias to represent record

from Orders --> This represents the table where the record is being read.

17. Ano ang tawag sa pahina ng Excel?
a. Column
b. Columnar
c. Sheet page
d. Spread sheet​

Answers

D

Explanation:

D.spread sheet

........,,............:-)

What may make it easy for cybercriminals to commit cybercrimes? Select 2 options.

Cybercrimes are not classified as real crimes, only as virtual crimes.

They operate from countries that do not have strict laws against cybercrime.

They are not physically present when the crime is committed.

The United States has no law enforcement that acts against them.

Law enforcement agencies lack the expertise to investigate them.

Answers

Answer: They operate from countries that do not have strict laws against cybercrime.

They are not physically present when the crime is committed.

Explanation:

edg

Answer:

They operate from countries that do not have strict laws against cybercrime.

They are not physically present when the crime is committed.

Explanation:

What will happen if there is no reply to the email confirmation?

A.The account will not be activated
B.The account will be Activated
C.The screen will display the message registration form available
D. The screen will display the message registration form unavailable

Answers

Answer:

A. the account will not be activated

Suppose you attend a party. To be sociable, you will shake hands with everyone else. Write the algorithm that will compute the total number of handshakes that occur. (Hint: Upon arrival, each person shakes hands with everyone who is already there. Use the loop to find the total number of handshakes as each person arrives.)

Answers

Answer:

Following are the flowchart to the given question:

Explanation:

Under which command group will you find the options to configure Outlook rules?
O Move
O New
O Quick Steps
O Respond

Answers

Answer:

Move

Explanation:

I hope that helps :)

Answer:

a). move

Explanation:

edge 2021 <3

what is the address of the first SFR (I/O Register)​

Answers

Answer:

The Special Function Register (SFR) is the upper area of addressable memory, from address 0x80 to 0xFF.

Explanation:

The Special Function Register (SFR) is the upper area of addressable memory, from address 0x80 to 0xFF.

Reason -

A Special Function Register (or Special Purpose Register, or simply Special Register) is a register within a microprocessor, which controls or monitors various aspects of the microprocessor's function.

Computer programming 5

Answers

Good luck this is the last one

Is there SUM in Small basic? ​

Answers

Answer:

no

Explanation:

A (n) ___ system can help a business alleviate the need for multiple information systems.

Answers

Answer:

Enterprise Resource Planning

Explanation:

ERP

steps on how to install a mouse​

Answers

Answer:

Verify that the mouse you're thinking of purchasing is compatible with your laptop model. ...

Plug the mouse's USB cable into the matching port on the side of your laptop.

Restart your computer while the mouse is connected. ...

Move your mouse a few times to confirm that the cursor responds.

1) Plug in your mouse's receiver.

2) Make sure that your mouse has batteries or is charged.

3) Turn on your mouse.

4) Press your mouse's "Connect" button.

5) Move your mouse around to test the connection.


Hope that helps.

Consider the following code: x = 9 y = -3 z = 2 print ((x + y) * z) What is output?

Answers

The answer will be 3
Other Questions
Six years ago a man's age was six times the age of his son. Four years hence, thrice his age will be equal to eight times his son's age. find their percent ages. prepare a calendar for August 2021 in which Saturday is on 14th. Do you think large multinational corporations in general like Wal-Mart, Apple, McDonalds and Frito Lay are good or bad for the world? Is "globalization" another word for Americanization? Why or why not? (3 points) Explain using complete sentences. EASY!!!!! ILL MARK BRAINLIEST!!!!!!!!why does measured current differ from calculated current Which of the following statements are true? Select all that apply.aS30 138A. p | q if 22 2 23.B. p | q if 25 27.C. r | s if Z2 = 24.D. r | s if 25 26. What developments helped strengthen national unity in this period? After studying all night, Caitlyn was able to describe the process with ________________ accuracy. Question Blank Can someone show me how to do this? Im not sure how to do thisDirections: The points in the table lie on a line. Find the slope of the line. Then draw its graph. Please help a brotha out so I can get ungrounded!Will give Brainlyest! Giving Brainliest, easy question 5. Using the factor tree, What are the prime factors of 36 own words. how how can we find the address of a cell. Here's a riddleA horse travels a certain distance each day. Strangely enough, two of its legs travel 30 miles each day and the other two legs travel nearly 31 miles. It would seem that two of the horse's legs must be one mile ahead of the other two legs, but of course, this can't be true, since the horse is normal. How is this possible?You can search the answer Cathy, a 125lb actress playing Peter Pan, is hoisted above the stage in order to fly by a stagehand pulling on a compound pulley system that has 6 supporting strands with a force of 30lbs. A) What is the ideal mechanical advantage of the pulley? Solve for x. Round your answer to the nearest tenth three ways in which a school can adress discrimination Simplify the expression 5(x+2x)+(3*5)+(4)(x) which of the following is correct statement ? A. a set of instructions is called programB.computers can be used for diagnosing the difficulty of a student in learning a subject . C. psychological testing can be done with the help of computer provided software is available. D. all of the above to find the number of atoms look at the number known as the________. Please help. SPANISH PLEASE HELP 1. Prefieres los vestidos de lana o los de seda?2. Qu color de ropa te queda bien?3. Qu ropa compras cuando vas de vacaciones?