Exercise 5.4 (15 points) Examples of palindrome are as follows: civic, level, ro
ID: 3905444 • Letter: E
Question
Exercise 5.4 (15 points) Examples of palindrome are as follows: civic, level, rotator Madam, I' m Adam. Was it a bar or a bat I saw? Was it a cat I saw? Doc, note, I dissent. A fast never prevents a fatness. I diet on cod. Write an algorithm to judge whether a string is palindrome Exercise 5.4 (15 points) Examples of palindrome are as follows: civic, level, rotator Madam, I' m Adam. Was it a bar or a bat I saw? Was it a cat I saw? Doc, note, I dissent. A fast never prevents a fatness. I diet on cod. Write an algorithm to judge whether a string is palindrome Exercise 5.4 (15 points) Examples of palindrome are as follows: civic, level, rotator Madam, I' m Adam. Was it a bar or a bat I saw? Was it a cat I saw? Doc, note, I dissent. A fast never prevents a fatness. I diet on cod. Write an algorithm to judge whether a string is palindromeExplanation / Answer
If you have any doubts, please give me comment...
i=0
j = length(str)-1
str = str.tolower()
boolean isPalindrome = true
while(i<len/2)
if(is_special_character(str[i]))
i++
if(is_special_character(str[j]))
j--;
if(str[i]!=str[j])
isPalindrome = false
break
i++
j--
if(isPalindrome)
print "It is palindrome"
else
print "It is not palindrome"