answersLogoWhite

0

Let L = length of the string.

greatest integer (L/2) gives the number of pairs of characters that must be compared.

For example if there are 10 letters 10/2 = 5.

abcdeedcba

If there are 11 letters, 11/5= 5.5, also 5. The 6th letter won't matter in this palindrome because it doesn't have to match another character.

abcdefedcba

Once we have the number of pairs [L/2], we need only run a loop,

as 'i' goes from 1 to [L/2]

check that "character i" = "character L+1-i"

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

A Write the algorithm to concatenate two given strings?

a write the algorithm to concatenate two given string


What is the palidrome for a kind of reception given by the mayor of a city?

civic


How can the halting problem reduction be applied to determine the computability of a given algorithm?

The halting problem reduction can be used to determine if a given algorithm is computable by showing that it is impossible to create a general algorithm that can predict whether any algorithm will halt or run forever. This means that there are some algorithms for which it is impossible to determine their computability.


What are some examples of undecidable languages and how are they different from decidable languages?

Undecidable languages are languages for which there is no algorithm that can determine whether a given input string is in the language or not. Examples of undecidable languages include the Halting Problem and the Post Correspondence Problem. Decidable languages, on the other hand, are languages for which there exists an algorithm that can determine whether a given input string is in the language or not. Examples of decidable languages include regular languages and context-free languages. The key difference between undecidable and decidable languages is that decidable languages have algorithms that can always provide a definite answer, while undecidable languages do not have such algorithms.


How can one demonstrate that a language is decidable?

A language is decidable if there exists an algorithm that can determine whether any given input belongs to the language or not. To demonstrate that a language is decidable, one must show that there is a Turing machine or a computer program that can correctly decide whether any input string is in the language or not, within a finite amount of time.


What is complsexity of an algorithm?

Complexity of an algorithm is a measure of how long an algorithm would take to complete given


How do you write method pubic boolean containsString s Return whether the given string is in the array or not?

Return an iterator to the string if it exists, or the container's end iterator if it does not.


Is the halting problem a decidable problem?

No, the halting problem is undecidable, meaning there is no algorithm that can determine whether a given program will halt or run forever.


Is the halting problem undecidable?

Yes, the halting problem is undecidable, meaning that there is no algorithm that can determine whether a given program will halt or run indefinitely.


How can one prove that the language is decidable?

To prove that a language is decidable, one must show that there exists a Turing machine that can determine whether a given input string belongs to the language in a finite amount of time. This can be done by providing a clear algorithm or procedure that the Turing machine follows to make this determination.


Write an algorithm to check whether the given number is odd or even?

Type your answer here... i think we should first enter 1 number then check it


Why algorithm needs to solve programming problem?

This is the definition of an algorithm - a list of orders of how to solve a given programming problem.