Recursion Exercises
-
7.28 (Palindromes) A palindrome is a string that’s spelled the same way forward and backward. Examples of palindromes include “radar” and “able was i ere i saw elba.” Write a recursive function
testPalindromethat returnstrueif astringis a palindrome, andfalseotherwise. Note that like anarray, the square brackets ([]) operator can be used to iterate through the characters in astring. -
7.29 (Eight Queens) Modify the Eight Queens program you created in Exercise 7.24 to solve the problem recursively.
-
7.30 (Print an
array) Write a recursive functionprintArraythat takes anarray, a starting subscript and an ending subscript as arguments, returns nothing and prints thearray. The function should stop processing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access