Dividing Recurrence Relation 1
function test(n) {
if (n > 1) {
console.log(n);
test(n / 2);
}
}When a function takes a parameter n, it can make it smaller by either subtracting like or dividing like or .
Amount of work is
Recurrence Relation Dividing
Tree Method
Each level does 1 unit of work across levels.
Assuming , we get , which simplifies to .
Since there’s one unit of work per level, the total work equals the number of levels: .
Substitution Method
Starting with , we substitute repeatedly:
Generalizing to iterations:
Assuming , we get and .
Substituting:
Answer:
Dividing Recurrence Relation 2
Recurrence Relation
Tree Method

Each level does amount of work.
So for each level,
This simplifies to n * 1
so answer is
Substitution Method
Starting with :
Assuming , we get and .
Answer:
Dividing Recurrence Relation 3
function test(n) {
if (n > 1) {
for (let i = 0; i < n; i++) {
console.log(n);
}
test(n / 2);
test(n / 2);
}
}The recurrence relation is
Tree Method
Each row adds up to amount of work: the 2nd row has two s, the 3rd row has four s, and so on. Each row contributes work.
Assuming , we get and .
Since work is done across levels, the total work is .
Substitution Method
Starting with , we substitute :
Continuing for iterations:
Assuming , we get and .
Master’s Theorem for Dividing Functions
For recurrences of the form where , , and :
Case 1:
Then
Case 2:
- Case 2.1: If , then
- Case 2.2: If , then
- Case 2.3: If , then
Case 3:
- Case 3.1: If , then
- Case 3.2: If , then
Examples
Case 1
Example 1:
Here , , and , so and .
Since , this is case 1. Answer:
Example 2:
Here , , . Since , this is case 1. Answer:
Example 3:
Here . Case 1, so
Example 4:
Here . Still case 1, so
Example 5:
Here . Case 1, so
Case 2
Example 1:
Here and , so they’re equal (case 2). Since has no term, . Answer:
Example 2:
Here , so case 2 with . Answer:
Example 3:
Here , so case 2 with . Answer:
Example 4:
Here , so case 2 with . Answer:
Example 5:
Note that . Here and (in denominator), so case 2.2. Answer:
Example 6:
Here and (in denominator), so case 2.3. Answer:
Case 3
Example 1:
Here , so case 3.1. Answer:
Example 2:
Here , so case 3.1—take the entire . Answer:
Example 3:
Here . Since log is in the denominator, this is case 3.2—just take . Answer:
Master’s Theorem Summary Tables
Case 1:
| Recurrence | Result |
|---|---|
Case 2:
| Recurrence | Result |
|---|---|
Case 3:
| Recurrence | Result |
|---|---|
Root Function (Recurrence Relation)
function test(n){
if(n>2) {
stmt
test(Math.sqrt(n))
}
}
Expanding by substitution:
Generalizing to iterations:
Let . Then .
Assuming , we need , so and .
Since , we have , giving us .
Answer: