Professional Documents
Culture Documents
Theory of Autamata
Computer Science
02 06-05-
20
Assessment Item Title: Due Date/Time:
I declare that this assessment item is my own work unless otherwise acknowledged and is
in accordance with the University’s academic integrity policy.
I certify that this assessment item has not been submitted previously for academic credit in
this or any other course. I certify that I have not given a copy or have shown a copy of this
assessment item to another student enrolled in the course.
I acknowledge that the assessor of this assignment may, for the purpose of assessing this
assignment:
Reproduce this assessment item and provide a copy to another member of the Faculty; and/or
Communicate a copy of this assessment item to a plagiarism checking service (which may then
retain a copy of the item on its database for the purpose of future plagiarism checking).
Submit the assessment item to other forms of plagiarism checking.
I certify that any electronic version of this assessment item that I have submitted or will
submit is identical to this paper version.
A recursive function is a function that calls itself during its execution. This enables the function
to repeat itself several times, outputting the result and the end of each iteration. Below is an
example of a recursive function.
function Count (integer N)
if (N <= 0) return "Must be a Positive Integer";
if (N > 9) return "Counting Completed";
else return Count (N+1);
end function
The function Count() above uses recursion to count from any number between 1 and 9, to the
number 10. For example, Count(1) would return 2,3,4,5,6,7,8,9,10. Count(7) would return
8,9,10. The result could be used as a roundabout way to subtract the number from 10.
EXAMPLE The function f (n) = 2n , where n is a natural number, can be defined recursively as
follows:
For any particular n, this procedure could be programmed by first initializing F = 1, and then
executing a loop “For i = 1 to n, 2 ∗ F = F.”
Here is how the definition gives us the first few powers of 2: 21 = 20+1 = 20 · 2 = 2
22 = 21+1 = 21 · 2 = 2 · 2 = 4
23 = 22+1 = 22 · 2 = 4 · 2 = 8
Discussion
Starting with the initial condition, f (0) = 1, the recurrence relation, f (n + 1) = (n + 1)f (n),
tells us how to build new values of f from old values. For example,
1! = f (1) = 1 · f (0) = 1,
2! = f (2) = 2 · f (1) = 2,
When a function f (n), such as the ones in the previous examples, is defined recursively, the
equation giving f (n + 1) in terms of previous values off is called a recurrence relation.
1. 1 ∈ S,
2. If x ∈ S, then 2 · x ∈ S.
1. 0, 1 ∈ S,
2. If x, y ∈ S, then x · y ∈ S.
1. f (0) = 0,
Therefore, by the first principle of mathematical induction fn is injective for all positive
integers.
EXAMPLE Given a real number a = 0, define an for all natural numbers, n, inductively by
ƒ
1. Initial Condition: a0 = 1
2. Recursion: a(n+1) = an