













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The concept of recursive algorithms using examples of natural numbers, even integers, strings, and ackerman's function. It also covers the six commandments for writing recursive algorithms and the divide and conquer meta-technique. The document also includes a warning about the size of the results produced by ackerman's function.
Typology: Slides
1 / 21
This page cannot be seen from the preview
Don't miss anything!














Example 1. The Set of Natural Numbers
Basis Clause: 0 εN
Inductive Clause: For any element x in N , x + 1 is in N. Extremal Clause: Nothing is in unless it is obtained from the Basis and Inductive Clauses. The basis for this set N is { 0 }. The x + 1 in the Inductive Clause is the parent of x , and x is the child of x + 1. Following this definition, the set of natural numbers N can be obtained as follows: First by (1), 0 is put into N. Then by (2), since 0 is in N , 0 + 1 (= 1) is in N. 0 is the parent of 1 , and 1 is the child of 0. Then by (2) again, 1 + 1 (= 2) is in N. 1 is the parent of 2 , and 2 is the child of 1. Proceeding in this manner all the natural numbers are put into N. Note that if we don't have (3), 0.5, 1.5, 2.5, ... can be included in N , which is not what we want as the set of natural numbers.
Example 3. The Set of Strings over the alphabet {a,b} excepting empty string This is the set of strings consisting of a 's and b 's such as abbab , bbabaa , etc.
Basis Clause: aεS , and baεS. Inductive Clause: For any element x in S , ax , and bx εS. Here ax means the concatenation of a with x. Extremal Clause: Nothing is in S unless it is obtained from the Basis and Inductive Clauses
Six Commandments for Writing Recursive Algorithms
**1. You must be able to define the problem.
Try it out on some inputs. Warning: Try very small inputs first, because the result gets very big very fast.
This function isn't very useful, except as a function that grows faster than probably any one you've seen before. (In technical jargon, the function is not primitive recursive.)
Here's the definition of a strange numerical function on natural numbers, called Ackerman's Function:
A(m,n) = 0, if n=
= 2n, if n>0 and m= = 2, if n=1 and m> = A(m-1,A(m,n-1)), if n>1 and m>