Discussion in 'C' started by desiram, Nov 16, 2006.
Write a program that uses a recursive function to determine if a string is a palindrome
Recursion in computer programming defines a function in terms of itself.A function that calls itself repeatedly, satisfying some condition is called a Recursive Function. Using recursion, we split a complex problem into its single simplest case. The recursive function only knows how to solve that simplest case.
To view a few recursion examples checkout this thread http://www.go4expert.com/showthread.php?t=1527&highlight=recursion
recursive function is nothing but the function calls itself untill the given condition fails...but these recursive functions aren`t that much recomended ,because they will occupy more stack space...i.e genarally when the function is called it occupies one stack frame....when recursive functions are used more more stack sapce is allocated to complete the stack....
code for recursive function to reverse the string ....
can u guess what is happening in the above program...as the strev is called recursively....it is occupieing stack frames char by char...as the stack works on LIFO principle....while retriving it prints in reverse order....then u can check..whether the given string and resulted strings are equal are not....if they are equal guven string is palindrome
Most of the time iterative solution is better than recursive one.
Separate names with a comma.