Lecture11Recursion

# Lecture11Recursion - Recursion A method of problem solving...

This preview shows pages 1–10. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Recursion A method of problem solving Recursion The term refers to the fact that the same computation recurs or occurs repeatedly, as the problem is solved. A recursive computation solves a problem by using the solution of the same problem with simpler inputs Palindrome Example A man, a plan, a canal Panama! Go hang a salami, Im a lasagna hog Madam, Im Adam Palindrome Example: madam Are first and last letters the same? If not, it is not a palindrome If yes, remove first and last and examine the shorter word: ada Palindrome Example: ada Are first and last letters the same? If not, it is not a palindrome If yes, remove first and last and examine the shorter word: d Palindrome Example: d This is a simple case and it is answered yes. So, ada is also answered yes And madam is also answered yes Find solutions to simplest case(s) Strings with a single character The empty string isPalindrome() in java public class Sentence {...
View Full Document

## Lecture11Recursion - Recursion A method of problem solving...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online