## Solving recurrence relation $T(n) \leq \sqrt{n}T(\sqrt{n}) + n$

Given the condition: $$T(O(1)) = O(1)$$ and $$T(n) \leq \sqrt{n}T(\sqrt{n}) + n$$. I need to solve this recurrence relation. The hardest part for me is the number of subproblems $$\sqrt{n}$$ is not a constant, it’s really difficult to apply tree method and master theorem here. Any hint? My thought is that let $$c = \sqrt{n}$$ such that $$c^2 = n$$ so we have $$T(c^2) \leq cT(c) + c^2$$ but I does not look good.

## Is My Recurrence Solution Correct? (Substitution method)

nvmnvmnvmnvmnvmnvmnvmnvmnvmnvmnvmnvmnvmnvm

## Recurrence with a function of n times T()

The master method works well on problems like $$T(n)=kT(an)+cn$$, but it does not handle problems like $$T(n)=n^{\frac{1}{3}}T(n^{\frac{2}{3}})+n^2$$ With the number of branches for each partition is a function of $$n$$. I wonder if there’s a good solution to this kind of problems, I have no idea how to solve this, any help is appreciated!

## solving recurrence T(n) = T(√n) + theta((lg lg n))

The solution given says that let m = lg n. Recurrence becomes S(m) =S(m/2) + theta(lgm). Case 2 of master’s theorem applies. But how come case

## Forming recurrence relations

I have this 2 examples in my textbook:

Example 1

public void f(int n) {     if (n = 1)         return 1;     else         return n * f (n-1); } 

The textbook shows how the recurrence relation is being form from by the above code

T(0) = a           for some constant a T(n) = T(n-1)+b    for some constant b and a recursive term 

Example 2

public int myFunction (int n) {     if (n == 1)         return 1;     else         return 2 * myFunction(n/2) + myFunction(n/2) + 1; } 

The textbook shows how the recurrence relation is being form from by the above code

T(1) = c              for some constant c T(n) = 2T(n/2) + b    for some constant b and a recursive term 

The problem

Despite reading the textbook multiple time (and failed attempt at searching online), I still do not understand how the +b come about for both examples. Is anyone able to enlighten on this?

Thanks.

## Recurrence relation for the number of “references” to two mutually recursive function

I was going through the Dynamic Programming section of Introduction to Algorithms(2nd Edition) by Cormen et. al. where I came across the following recurrence relations in the assembly line scheduling portion.

$$(1),(2),(3)$$ are three relations as shown.

$$f_{1}[j] = \begin{cases} e_1+a_{1,1} &\quad\text{if } j=1\ \min(f_1[j-1]+a_{1,j},f_2[j-1]+t_{2,j-1}+a_{1,j})&\quad\text{if} j\geq2\ \end{cases}\tag 1$$

Symmetrically,

$$f_{2}[j] = \begin{cases} e_2+a_{2,1} &\quad\text{if } j=1\ \min(f_2[j-1]+a_{2,j},f_1[j-1]+t_{1,j-1}+a_{2,j})&\quad\text{if} j\geq2\ \end{cases}\tag 2$$

(where $$e_i,a_{i,j},t_{2,j-1}$$ are constants for $$i=1,2$$ and $$j=1,2,3,…,n$$)

$$f^\star=\min(f_1[n]+x_1,f_2[n]+x_2)\tag 3$$

The text tries to find the recurrence relation of the number of times $$f_i[j]$$ ($$i=1,2$$ and $$j=1,2,3,…,n$$) is referenced if we write a mutual recursive code for $$f_1[j]$$ and $$f_2[j]$$. Let $$r_i(j)$$ denote the number of times $$f_i[j]$$ is referenced.

They say that,

From $$(3)$$,

$$r_1(n)=r_2(n)=1.\tag4$$

From $$(1)$$ and $$(2)$$,

$$r_1(j)=r_2(j)=r_1(j+1)+r_2(j+1)\tag 5$$

I could not quite understand how the relations of $$(4)$$ and $$(5)$$ are obtained from the three corresponding relations.

Thought I could make out intuitively that as there is only one place where $$f_1[n]$$ and $$f_2[n]$$ are called, which is in $$f^\star$$, so probably in $$(4)$$ we get the required relation.

But as I had not encountered such concept before I do not quite know how to proceed. I would be grateful if someone guides me with the mathematical prove of the derivation as well as the intuition, however I would prefer an alternative to mathematical induction as it is a mechanical cookbook method without giving much insight into the problem though (but if in case there is no other way out, then I shall appreciate mathematical induction as well provided the intuition is explained to me properly).

## trouble solving the recurrence 4T(n/2) + n

I am having trouble figuring out how to solve this recurrence problem…

\begin{aligned} &4T(n/2) + n \ = &4(4T(n/4) + n/4) + n \ = &16T(n/4) + 2n \ = &4^kT(n/2^k) + kn \end{aligned}

I lose the trail here and I cannot figure out how to finish it and actually find the complexity. Can anyone help? How can this be done?

## Recurrence Relations for Perfect Quad Trees (same as binary trees but with 4 children instead of 2)

I have to write and solve a recurrence relation for n(d), showing how I arrive at the formula and solve the recurrence relation, showing how I arrive at the solution. Then prove my answer is correct using induction for perfect quad trees which are basically binary trees but with 4 children at each node rather than 2 and the leaf nodes in the deepest layer have no children. Nodes at precisely depth d is designated by n(d). For example, the root node has depth d=0, and is the only node at that depth, and so n(0) = 1

Does this mean it would be T(n)= 4T(n/4) + d ? then prove

I’m really confused and would appreciate any help or resources.

## How to solve recurrence $T(n) = 5T(\frac{n}{2}) + n^2\lg^2 n$

I have tried solving it using substitution. Apparently, it is exact for some $$n$$ and the order of the general solution can be found from this exact solution.

By substitution I got the following (not sure if it is correct):

$$T(n) = 5^kT(n) + \sum_{i = 0}^{k}{5^{i}\left(\frac{n}{2^{i}}\right)^{2}\lg^{2}\left(\frac{n}{2^{i}}\right)}$$

I am not sure how to proceed from this. I don’t even know if this approach is correct so far. How do I solve this recurrence?

## closed form for the following recurrence relation

$$t(k,m,n) = \frac{m}{k}t(k-1,m-1,n-1)+ \frac{k-m}{k} t(k-2,m-1,n-1) + \frac{k-m}{k}$$ , where $$k \geq m \geq n$$