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
earnstyle [38]
3 years ago
7

Write a function check_halves() that recursively processes the first half and second half of a string, counting how many letters

the halves have in common, stopping when the first mismatch is found

Computers and Technology
1 answer:
Sholpan [36]3 years ago
5 0

Answer:

The program code is at explaination

Explanation:

Below is the Python Function;

def check_halves(s):

# exact half not possible condition

if len(s)%2!=0:

return 0

halflen=len(s)//2

s1=s[:halflen]

s2=s[halflen:]

#null string condition

if len(s1)==0 or len(s2)==0:

return 0

#checking 1st digit of string recursively

if s1[0]==s2[0]:

return 1+check_halves(s1[1:]+s2[1:])

else:

return 0

You will find the input and output ad attachment.

You might be interested in
Describe a recent situation where you have had to use your critical thinking skills. Describe the problem and how you went about
Sophie [7]
I had 7 assignments all do at the same time for different classes. They were all incredibly tedious so I strategized and did the assignments that I knew well first, then completed the others. I evaluated the pros and cons of this strategy and decided that if I had done the harder ones first it would have taken more time and I would have been too stressed to complete the others. I hope that helps!
6 0
3 years ago
When typing in a cell, hitting Tab will bring which result?
iren2701 [21]

<span>C. 
Move to the next cell down.</span>
7 0
3 years ago
Read 2 more answers
What are possible consequences for cyberbullying?
MrRa [10]

Answer:

Victims of cyberbullying are more likely than their peers to abuse alcohol and drugs, have physical and emotional health issues, and may suffer from low self-esteem. Poor grades in school is another consequence of cyberbullying that can also be accompanied by an attempt by the victim to avoid other children by refusing to go to school.

Explanation:

8 0
3 years ago
Read 2 more answers
What is Recursion in Java?
wel

Answer:

Recursion is a process of defining a method that calls itself repeatedly

Explanation:

Recursion is a basic programming technique of defining a method that calls itself repeatedly.

One practical example is using recursion to find the factorial of a number.

Consider the following java code below, it uses recursion to solve for the factorial of a number.

class Main {

   public static void main (String[] args) {

       System.out.println("Factorial of 3 is " + factorial(3));

       System.out.println("Factorial of 5 is " + factorial(5));

       System.out.println("Factorial of 7 is " + factorial(7));

   }

   //the factorial method uses recursion to find the factorial of the

   // parameter of the integer pass into it

   

   private static int factorial(int n) {

       int result;

       if ( n ==1) return 1;

       result = factorial(n-1) * n;

       return result;

   }

}

6 0
3 years ago
Two columns of a relational table can have the same names. <br> a. True <br> b. False
Leto [7]
B, false

two columns must have a unique name
3 0
3 years ago
Other questions:
  • A(n) ____________ is a program that translates a high-level language program into a separate machine language program.
    7·1 answer
  • Declarative knowledge refers to statements of fact.
    5·1 answer
  • Stating a document is PDF or XPS document refers to document _______​
    10·1 answer
  • A program that processes data submitted by the user. Allows a Web server to pass control to a software application, based on use
    11·1 answer
  • Which organization plays a key role in development of global health informatics?
    9·1 answer
  • Computers have drastically changed society over the last 20 years. How have computers affected communication in the business wor
    8·1 answer
  • 15
    9·2 answers
  • Whats the difference between Input and Output? Give and example of an example on a M:B​
    15·1 answer
  • Which option would a computer engineer most likely create? A) a programming language to run a new software program B.) the part
    11·1 answer
  • How to mark a discussion as read on canvas dashboard.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!