Basically I have an assignment to check weather a string is a palindrome, like dad, is a palindrome or not. The problem is I'm required to use recursion. I'm actually a bit confused on this one, if a recursive function is just a function that solves a problem by reducing it to smaller version of itself, then does that mean I can't use any form of a loop here? I thought of the following algorithm.
1) Get c-string
2) Use modulus to determine if indexSize is even or not
3) Use for loop to compare front index to back index...eg first and last
4)increase first counter, decrease second counter...
5)if index was an odd number…then if statement within the loop would compare middle index to middle index then break.
but that would involve irritation...
so I’m not really sure I’m getting the point...
any advice would be greatly appeared.
Oh and please do not post code solving my problem, I do the work and take the class to understand how to become a better programmer.
2006-11-04
05:33:01
·
3 answers
·
asked by
D
4
in
Computers & Internet
➔ Programming & Design
I code in multiple languages but this assignment is to be done in C++
2006-11-04
06:08:06 ·
update #1