1. ## palindrome recursion

I am asked to write the following, which for me seems to be pretty stupid

Write a recursive function that takes as an input two strings s1, s2 and checks whether one is a palindrome of the other

If s1 and s2 are palindrome of each other then it means that they are equal right? I mean s1 and s2 are equal? So why do I need to write a recursion for this, just use a strcmp of both strings and it should be done. Or am I misunderstanding the question

2. apparently "never even" is a valid palindrome (according to Wikipedia)

so just comparing the two strings isn't enough

3. ok, so how do I write this function then? is the base case when we're only comparing a char and if both char are equal then we return 1, indicating it's a palindrome otherwise we just do a substring of the string...

4. What is a palindrome? You need to get that right first.

5. Originally Posted by laserlight
What is a palindrome? You need to get that right first.
Palindrome - Wikipedia, the free encyclopedia

6. Originally Posted by ಠ_ಠ
Yes, that article makes the same point: there are multiple definitions. If your definition does not match your instructor's definition, then your solution will be wrong. In any case, your currently used definition (i.e., "string equality") does not match any definition of "palindrome" that I know of.

7. Originally Posted by -EquinoX-
ok, so how do I write this function then? is the base case when we're only comparing a char and if both char are equal then we return 1, indicating it's a palindrome otherwise we just do a substring of the string...
I think you could concatenate the two strings and compare the start and end(skipping the '\0' char at the very end) of the new string, you might need to remove any spaces depending on your input

8. Originally Posted by ಠ_ಠ
I think you could concatenate the two strings and compare the start and end(skipping the '\0' char at the very end) of the new string, you might need to remove any spaces depending on your input
I do not think that string concatenation is needed even for a recursive solution. For the string to be compared in the forward direction, just some pointer arithmetic should suffice. For the string to be compared in the reverse direction, (assuming the requirements permit it) some index could be used and thus it would be the index that is changed.

9. Originally Posted by laserlight
I do not think that string concatenation is needed even for a recursive solution. For the string to be compared in the forward direction, just some pointer arithmetic should suffice. For the string to be compared in the reverse direction, (assuming the requirements permit it) some index could be used and thus it would be the index that is changed.
would that allow for different sized strings?

10. Originally Posted by ಠ_ಠ
would that allow for different sized strings?
Yes, assuming an index is used for the backward direction. If not, it might be a little difficult since there is no way of knowing when you have reached to before the front of the string (and hence are with with an "empty string", recursively speaking).