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
nekit [7.7K]
2 years ago
15

A palindrome is a string that reads the same from left to right and from right to left. Design an algorithm to find the minimum

number of characters required to make a given string to a palindrome if you are allowed to insert characters at any position
Computers and Technology
1 answer:
stepladder [879]2 years ago
3 0

Answer:

Explanation:

The following code is written in Python. It is a recursive function that tests the first and last character of the word and keeps checking to see if each change would create the palindrome. Finally, printing out the minimum number needed to create the palindrome.

import sys

def numOfSwitches(word, start, end):

   if (start > end):

       return sys.maxsize

   if (start == end):

       return 0

   if (start == end - 1):

       if (word[start] == word[end]):

           return 0

       else:

           return 1

   if (word[start] == word[end]):

       return numOfSwitches(word, start + 1, end - 1)

   else:

       return (min(numOfSwitches(word, start, end - 1),

                   numOfSwitches(word, start + 1, end)) + 1)

word = input("Enter a Word: ")

start = 0

end = len(word)-1

print("Number of switches required for palindrome: " + str(numOfSwitches(word, start, end)))

You might be interested in
Which file extension takes less storage space?
anyanavicka [17]

I believe the answer would be the JPEG file extension.

4 0
3 years ago
Read 2 more answers
XYZ Corp.’s facilities in Nashua, New Hampshire, are two office buildings 400 feet apart, each with its own LAN. To connect the
damaskus [11]

Answer:

a: Twisted pair won't span a 400-foot distance.

Explanation:

The maximum distance that twisted pair cables can support without attenuation is 100 meters which is approximately 328 feet and the two office buildings are 400 feet apart, so it is useless to install a twisted pair cable for such a large distance. A much better option would be to install optic fiber. Though it is a bit expensive but it is the best option in this case.

Hence option (a) is the correct reason for installing an optic fiber cable rather than a twisted pair cable.

6 0
3 years ago
PLZ HELP ME I WILL GIVE BRAINLIST!!! Why was the Internet originally constructed?
pochemuha

Answer:

C. to provide online search capabilities

Explanation:

The first workable prototype of the Internet came in the late 1960s with the creation of ARPANET, or the Advanced Research Projects Agency Network. Originally funded by the U.S. Department of Defense, ARPANET used packet switching to allow multiple computers to communicate on a single network.

5 0
2 years ago
Which of the following is a benefit of a digital network?
k0ka [10]

Answer:

Multiple devices can be connected

8 0
2 years ago
Can you list the answers in order
viva [34]

whats the question?????????????????????

5 0
2 years ago
Other questions:
  • What does the picture indicate on the famous book “Dawn of the century”?​
    10·1 answer
  • What is a constructor? Why would you include a constructor in a class?
    6·1 answer
  • Write structured pseudocode to show the following: print “Reorder” when the quantity is less than 20; otherwise print “OK”.
    15·1 answer
  • A software EULA is an agreement related to which of the following?
    11·2 answers
  • Community gardens are public gardens where local residents can grow plants in a plot. They are very popular, so there are often
    7·1 answer
  • Write a program that reads a list of integers, and outputs whether the list contains all even numbers, odd numbers, or neither.
    5·1 answer
  • Write a summary of five things that you learned about CSS. Do not copy and paste the information. Summarize each point in your o
    5·1 answer
  • Is monitor is a television​
    5·2 answers
  • 24/3*2^2/2*3+(20-10)-40
    9·1 answer
  • Means storing,accessing information over the internet other than hard drive and your system
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!