Recursion and Recursive Definitions: Sets, Strings, Sequences, Functions, and Algorithms, Study notes of Number Theory

An in-depth exploration of recursion and recursive definitions, covering various applications such as sets, strings, sequences, functions, and algorithms. Topics include recursive definitions for sets and strings, recursive algorithms for factorial, n choose k, and gcd, and the conversion of recursive definitions to recursive algorithms.

Typology: Study notes

2010/2011

Uploaded on 11/05/2011

yorket
yorket 🇺🇸

4.4

(38)

276 documents

1 / 68

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Recursion
Zeph Grunschlag
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44

Partial preview of the text

Download Recursion and Recursive Definitions: Sets, Strings, Sequences, Functions, and Algorithms and more Study notes Number Theory in PDF only on Docsity!

Recursion

Zeph Grunschlag

Agenda

Recursion and Induction

Recursive Definitions

 Sets  Strings

Recursive Algorithms

Recursive Definitions

and Induction

Recursive definition and inductive proofs are complement each other: a recursive definition usually gives rise to natural proofs involving the recursively defined sequence.

This is follows from the format of a recursive definition as consisting of two parts:

  1. Initialization – analogous to induction base cases
  2. Recursion – analogous to induction step

In both induction and recursion, the domino analogy is useful.

Recursive Functions

It is possible to think of any function with domain

N as a sequence of numbers, and vice-versa.

Simply set: fn =f (n)

For example, our Fibonacci sequence becomes

the Fibonacci function as follows:

f (0) = 0, f (1) = 1, f (2) = 1, f (3) = 2,…

Such functions can then be defined recursively by

using recursive sequence definition. EG:

INITIALIZATION: f (0) = 0, f (1) = 1

RECURSION: f (n)=f (n -1)+f (n -2), for n > 1.

Recursive Functions

Factorial

A:INITIALIZATION: 0!= 1

RECURSION: n != n · (n -1)!

To compute the value of a recursive function, e.g. 5!, one plugs into the recursive definition obtaining expressions involving lower and lower values of the function, until arriving at the base case.

EG: 5! =

Recursive Functions

Factorial

A:INITIALIZATION: 0!= 1

RECURSION: n != n · (n -1)!

To compute the value of a recursive function, e.g. 5!, one plugs into the recursive definition obtaining expressions involving lower and lower values of the function, until arriving at the base case.

EG: 5! = 5 · 4!

recursion

Recursive Functions

Factorial

A:INITIALIZATION: 0!= 1

RECURSION: n != n · (n -1)!

To compute the value of a recursive function, e.g. 5!, one plugs into the recursive definition obtaining expressions involving lower and lower values of the function, until arriving at the base case.

EG: 5! = 5 · 4! = 5 · 4 · 3! = 5 · 4 · 3 · 2!

recursion

Recursive Functions

Factorial

A:INITIALIZATION: 0!= 1

RECURSION: n != n · (n -1)!

To compute the value of a recursive function, e.g. 5!, one plugs into the recursive definition obtaining expressions involving lower and lower values of the function, until arriving at the base case.

EG: 5! = 5 · 4! = 5 · 4 · 3! = 5 · 4 · 3 · 2!

recursion

L16 13

Recursive Functions

Factorial

A:INITIALIZATION: 0!= 1

RECURSION: n != n · (n -1)!

To compute the value of a recursive function, e.g. 5!, one plugs into the recursive definition obtaining expressions involving lower and lower values of the function, until arriving at the base case.

EG: 5! = 5 · 4! = 5 · 4 · 3! = 5 · 4 · 3 · 2!

recursion

initializatio

L16 14

Recursive Functions

n choose k

The Binomial coefficients arise in several

applications:

1) Combinatorics/Probability (n choose k):

C (n,k) = the number of different groups

of size k from an initial group of size n

2) Algebra:

C (n,k) = coefficient of k th^ term in the

expansion of the n th^ binomial power

(x + y )^ n

Commonly used notation:

k

n

C ( n , k )

n choose k

and Pascal’s Triangle

n choose k

and Pascal’s Triangle

n choose k

and Pascal’s Triangle

n choose k

and Pascal’s Triangle