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

Still curious? Ask our experts.

Chat with our AI personalities

SteveSteve
Knowledge is a journey, you know? We'll get there.
Chat with Steve
FranFran
I've made my fair share of mistakes, and if I can help you avoid a few, I'd sure like to try.
Chat with Fran
JordanJordan
Looking for a career mentor? I've seen my fair share of shake-ups.
Chat with Jordan
More answers

1. Generate a random word of length n

2. Take generated word and make a copy

3. Reverse copied word

4. Append to original word

User Avatar

Wiki User

8y ago
User Avatar

Add your answer:

Earn +20 pts
Q: Algorithm to find whether given string is palidrome?
Write your answer...
Submit
Still have questions?
magnify glass
imp