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
Sindrei [870]
3 years ago
10

Write a recursive method named editDistance that accepts string parameters s1 and s2 and returns the "edit distance" between the

two strings as an integer. Edit distance (also called Levenshtein distance) is defined as the minimum number of "changes" required to get from s1 to s2 or vice versa. A "change" can be defined as a) inserting a character, b) deleting a character, or c) changing a character to a different character. Call Value Returned editDistance("driving", "diving") 1 editDistance("debate", "irate") 3 editDistance("football", "cookies") 6
Computers and Technology
1 answer:
stepan [7]3 years ago
3 0

Answer:

Explanation:

The following code takes in the two parameters s1 and s2 and returns the Levenshtein distance of the two strings passed.

def editDistance(s1, s2):

   m = len(s1) + 1

   n = len(s2) + 1

   arr = {}

   for x in range(m):

       arr[x, 0] = x

   for y in range(n):

       arr[0, y] = y

   for x in range(1, m):

       for y in range(1, n):

           proc = 0 if s1[x - 1] == s2[y - 1] else 1

           arr[x, y] = min(arr[x, y - 1] + 1, arr[x - 1, y] + 1, arr[x - 1, y - 1] + proc)

   return arr[x, y]

You might be interested in
FREE 10 POINTS THE EASIEST QUESTION EVER I AM NEW SO I DONT KNOW HOW TO MARK SOMEONE THE BRAINLEAST ????????????????????????????
umka2103 [35]

Usually you can just report the question as useless or just report in in general. But I myself have read some answers and they dont even pertain to the question, it confuses me alot

8 0
3 years ago
Read 2 more answers
Vẽ sơ đồ lắp đặt gồm 2 cầu chì, 1 ổ điện, 2 cực điều khiển 2 đèn mắc song song
Nookie1986 [14]

Answer:

okokikhjhghjjjkkkkkokoloo

7 0
2 years ago
What is most likely to happen to the purchasing power of money over time?
natima [27]

Answer:

A

Explanation:

6 0
2 years ago
How can you make the drawing tools contextual tab appear
Anestetic [448]

Answer:

Following up on Stefan's repsonse, this means that first, from the Insert tab you need to insert a line or shape. Once you've inserted something, select it and the contextual tab DRAWING TOOLS - FORMAT will appear.

Explanation:

3 0
2 years ago
Read 2 more answers
You are the senior nurse on the unit and you are orienting a new graduate LVN/LPN. One of the subjects you want to cover today i
Margarita [4]

Answer: D. Homans sign

Explanation:

Check for the severity of the swelling, monitor the flow of blood to the tissue, pulses equality, check for homans sign such as pain in the leg around the calve, the calve is meant to be of equal size and warmth. There should not be any reddish colouration or pains around the calve when there is ankle movement as this shows a negative sign of homans.

3 0
2 years ago
Other questions:
  • What is an advantage of sharing documents in PDF format instead of Word format?
    6·2 answers
  • Write a program that utilizes the concept of conditional execution, takes a string as input, and: prints the sentence "Yes - Spa
    8·1 answer
  • Wich is the correct process for selecting an entire row in a spreadsheet?
    12·1 answer
  • What was bill gates first operating system he created?
    7·1 answer
  • What is the primary responsibility of the federal reserve bank??
    11·1 answer
  • When a climbing distance of __________, landing platforms must be in place every __________ feet. Platforms will be offset from
    12·1 answer
  • You are reviewing the output of the show interfaces command for the Gi0/1 interface on a switch. You notice a significant number
    12·1 answer
  • How can I use HTML to express a personal value
    13·1 answer
  • Assume the size of an integer array is stored in $s0 and the address of the first element of the array in the memory is stored i
    10·1 answer
  • Cite some improved technology this 2021?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!