20 likes | 108 Views
Program Design using Recursion. Recursion is a very powerful design (and programming) technique Consider using recursion when Designing algorithm for problem of “size” N, AND If you’re giving a problem of size N – m, you can add-to or alter that solution to solve the problem of size N.
E N D
Program Design using Recursion • Recursion is a very powerful design (and programming) technique • Consider using recursion when • Designing algorithm for problem of “size” N, AND • If you’re giving a problem of size N – m, you can add-to or alter that solution to solve the problem of size N.
Example Recursive Designs • Compute N ! (N factorial) • Determine if a string is a palindrome • Binary Search (of a sorted array) • Towers of Hanoi • Merge Sort • MANY data structure problems associated with trees, graphs, lists, …