Programmer's Wiki

A palindrome is a word or sentence that is the same when read backwards. In the case of sentences, spaces are ignored.

Detection of palindromes[]

This is an algorithm to detect palindromic words represented as a string of characters, in pseudocode. (Indices are one-based)

Input: s, a word to be tested
Output: true if the word is palindromic
for i = 1 to len(s)/2
  if(character of s at i is not equal to character of s at len(s) - i + 1)
    return false
return true