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
What is one of the main problems with shared web hosting? Select one: Sites that share resources are less susceptible to hacking
Pani-rosa [81]

Answer:

If one or more of the shared sites go down, then there is a good chance that your site will go down as well.

Explanation:

Shared web hosting is a form of web hosting service whereby more than one websites are placed on a single web server that connects to the internet.

Though it is cheaper, it has various problems. And over time, it has been concluded that the major problem associated with shared web hosting is the security issue.

This implies that "If one or more of the shared sites go down, then there is a good chance that your site will go down as well."

Some other problems associated with Shared web hosting are poor value, less flexibility, none advanced features, slow service, less support.

4 0
3 years ago
An administrator is writing into a database and received an error detailed in the exhibit. What two steps need to be taken to re
d1i1m1o1n [39]

An administrator is writing into a database and received an error detailed in the exhibit. The two steps to be taken to resolve this are :

Move the Execute SQL statement to be between Connect and Disconnect. Move the Prompt Message to be before the Disconnect statements.

Explanation:

  • Dynamic SQL refers to SQL statements that are generated at run-time.
  • To disconnect from a database, in the Database Navigator or Projects view, click the connection and then click the Disconnect button in the toolbar or click Database -> Disconnect on the main menu
  • You can also right-click the connection and click Disconnect on the context menu
  • The PROMPT command may be used to display messages to the user, perhaps supplying a short summary of what your script is going to accomplish.
  • The SQL EXECUTE command executes an SQL command and binds the result to 4D objects (arrays, variables or fields).
  • A valid connection must be specified in the current process in order to execute this command. The sqlStatement parameter contains the SQL command to execute.

7 0
3 years ago
1. Ce este o baza de date? (1p)
lesya [120]

Answer:

would you mind telling me what this says im still learning my spanish

Explanation:

6 0
2 years ago
Read 2 more answers
Your isp connects to the core routers of the internet via a _____. cable mode spine backbone satellite
melisa1 [442]

fairly certain its backbone

5 0
3 years ago
What is redo and undo?​
umka21 [38]

Answer:

Answer in the below

Explanation:

Redo means the previous one and undo means removing it... i am not so sure..

3 0
1 year ago
Other questions:
  • Give two examples of non printing characters
    6·1 answer
  • Emma has decided that she needs to assess the risk and return of buying an extended warranty for her new laptop for school
    15·1 answer
  • How do keystroke dynamics determine whether to authenticate an individual or not?
    14·1 answer
  • Jackson has completed remediation of a virus-infected system. He eliminated all the startup program issues and uninstalled sever
    8·1 answer
  • HELP 99PTS If Answered
    12·2 answers
  • In an income statement subtracting the cost of goods sold from the net sales provides the?
    11·1 answer
  • Which term is used in object-oriented programming to reference characteristics of an object?
    15·1 answer
  • Write a program that defines an array of integers and a pointer to an integer. Make the pointer point to the beginning of the ar
    12·1 answer
  • Evaluate a career in the telecommunications industry that most interests you. What about the career appeals to you?
    8·1 answer
  • How to install an older version of prettier on yarn
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!