Write a recursive function named non_matching that accepts two strings as parameters, and returns an integer...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a recursive function named non_matching that accepts two strings as parameters, and returns an integer representing the number of character indexes between the two strings that do not match. For this problem, two strings are defined as having a "match" at a given index if they contain exactly the same ASCII character value at that index. For example, consider the following two strings: # index 012345678901234 string s1 = "I love Mariana!" string s2 = "U Love Marty" In the above example, seven indexes do not match (underlined above for emphasis): indexes 0, 2, 10, 11, 12, 13, and 14. So the call of non_matching (s1, s2) would return 7. Any character could match or fail to match, including letters, numbers, spacing, punctuation, etc. Your function is case-sensitive notice that the 'I' and 'L' at index 2 do not match. If the two strings are not the same length, any indexes at the end of the longer string by definition do not match, since there is no character in the other string at that index that could correspond to them. One implication of this is that if one of the parameters is an empty string, the entirety of the other string is considered non-matching. Constraints: Do not use any loops you must use recursion. • Do not declare any global variables. • Do not call any string member functions or string library functions that traverse or search the entire string. Some examples of such functions are: find, rfind, string_index_of, string_contains, replace, string_split, etc. (The poof this problem is to solve it recursively do not use a library function to get around recursion.) • Do not use any auxiliary data structures like list, dict, set, etc. You can declare as many primitive variables like ints as you like, as well as strings. • You are allowed to define other "helper" functions if you like they are subject to these same constraints. Write a recursive function named non_matching that accepts two strings as parameters, and returns an integer representing the number of character indexes between the two strings that do not match. For this problem, two strings are defined as having a "match" at a given index if they contain exactly the same ASCII character value at that index. For example, consider the following two strings: # index 012345678901234 string s1 = "I love Mariana!" string s2 = "U Love Marty" In the above example, seven indexes do not match (underlined above for emphasis): indexes 0, 2, 10, 11, 12, 13, and 14. So the call of non_matching (s1, s2) would return 7. Any character could match or fail to match, including letters, numbers, spacing, punctuation, etc. Your function is case-sensitive notice that the 'I' and 'L' at index 2 do not match. If the two strings are not the same length, any indexes at the end of the longer string by definition do not match, since there is no character in the other string at that index that could correspond to them. One implication of this is that if one of the parameters is an empty string, the entirety of the other string is considered non-matching. Constraints: Do not use any loops you must use recursion. • Do not declare any global variables. • Do not call any string member functions or string library functions that traverse or search the entire string. Some examples of such functions are: find, rfind, string_index_of, string_contains, replace, string_split, etc. (The poof this problem is to solve it recursively do not use a library function to get around recursion.) • Do not use any auxiliary data structures like list, dict, set, etc. You can declare as many primitive variables like ints as you like, as well as strings. • You are allowed to define other "helper" functions if you like they are subject to these same constraints.
Expert Answer:
Answer rating: 100% (QA)
The image contains a problem statement which asks to write a recursive function named nonmatching th... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
A registered dealer, based in Chandigarh, makes a supply to another registered dealer located in Chandigarh, valuing rupees 1,20,000. The applicable rate of GST is 12%. Calculate the amount of tax...
-
Which is NOT a core value of community employment? A. Team makes decisions for the employment seeker B. Presumption of employment C. Focus on capacity and capabilities D. Importance of relationships...
-
The best or alpha project managers spend more time on every process group than other project managers except for which one? A. initiating B. planning C. executing D. monitoring and controlling
-
Design a series RCL circuit with R>= 1Kohm that has characteristic equation. S^2 + 4*10^6S +4*10^14 = 0
-
The percent p of wood lost in cutting it into boards 1.5 in. thick due to the thickness t (in in.) of the saw blade is Find p if t = 0.4 in. That is, since p = f (t), find f(0.4). P = 100t t + 1.5
-
a. Is a \(4 p ightarrow 4 s\) transition allowed in sodium? If so, what is its wavelength? If not, why not? b. Is a \(3 d ightarrow 4 s\) transition allowed in sodium? If so, what is its wavelength?...
-
Suppose that the nominal interest rate on three-month Treasury bills is 8 percent in the United States and 6 percent in the United Kingdom, and the rate of inflation is 10 percent in the United...
-
(a) Graph the equation 3x-5y=35 (b) Write the equation of the line satisfying the given conditions; the line contains the point (-6, 1) and is parallel to 2x-3y=6
-
Darcelle teaches skiing at the Snow School. Jack runs a ski shop called Up Hill, Down Hill. Their combined bank interest is $1,000. If they get a refund, they would like the money deposited into...
-
1.Market Feasibility - identifying the total market for a Mobile Sales (cellphone) company. Total size of market in Timmins - stats canada/TEDC websites 2. What industry code in this industry 3. A...
-
Analyze the following email exchange and share your analysis with your peers. To complete the assignment, address the following: Do you think these emails were effective or ineffective? Why? Identify...
-
Imagine that you are in a situation whereby you are a newcomer student in the USA. You have some English knowledge but you feel you face a language barrier, and you want to work but you don't know if...
-
Here you will research [Googling your response is fine for now] and post 2 results for professional organizations associated with your desired profession here. Please note: A Professional...
-
What is happening at a policy level that is perpetuating these health inequities? Are there laws that should be passed or changed? Lawsuits that should be filed? Do past warrant a reparations...
-
Required: Write the letters for the given scenarios, using the correct format and criteria for the specific type of letters. . Scenario for Good News Letter: Write a letter to your Subordinate...
-
For aGlcA p [1-3]GalNAc p Name the 2 sugars What are the sugars' conformations Which is the reducing sugar Which is the non-reducing sugar Which carbon atoms of the sugars are involved in the...
-
Wal-Mart is the second largest retailer in the world. The data file on the disk holds monthly data on Wal-Marts revenue, along with several possibly related economic variables. a) Using computer...
-
The principal argument in favor of dynamic scoping is that it facilitates the customization of subroutines. Suppose, for example, that we have a library routine print integer that is capable of...
-
Give a grammar that captures all levels of precedence for arithmetic expressions in C.
-
Translate the following expression into postfix and prefix notation: [b + sqrt(b b 4 a c)]/(2 a) Do you need a special symbol for unary negation?
-
What is the difference between a relational database schema and a database schema?
-
What are the common deletion rules to enforce referential integrity?
-
Use the information in the preceding question to create a prototype of the report; use an automated tool such as Microsoft Access (or if you prefer, you can create a prototype the old-fashioned way...
Study smarter with the SolutionInn App