Questions tagged [recursion]

Recursion is the process of repeating items in a self-similar way. A recursive definition (or inductive definition) in mathematical logic and computer science is used to define an object in terms of itself. A recursive definition of a function defines values of a function for some inputs in terms of the values of the same function on other inputs. Please use the tag 'computability' instead for questions about "recursive functions" in computability theory

Recursion is the process of repeating items in a self-similar way. The most common application of recursion is in mathematics and computer science, in which it refers to a method of defining functions in which the function being defined is applied within its own definition.

Basically, a class of objects exhibiting recursive behaviour can be characterised by two features:

  • There must be a base criterion for which the function should not call itself.

  • Every other iteration of the function should move it closer to the base condition.

2829 questions
8
votes
2 answers

Can every recursive formula be expressed explicitly?

I'm not sure if my wording is entirely correct, but I was just wondering if every recursive formula can be turned into an explicit formula. I am asking this because various sources online gives me opposite answers. Although, one thing I have…
krikara
  • 478
7
votes
4 answers

solve $T(n)=T(n-1)+T(\frac{n}{2})+n$

Using the recursion tree i tried solving this: $T(n)=T(n-1)+T(\frac{n}{2})+n$; the tree has two parts (branches) one that of $T(n-1)$ and other branch is of $T(\frac{n}{2})$. But as the term T(n-1) reach higher depth, I solved that part of the tree.…
studnt
  • 71
6
votes
3 answers

Solve the recurrence $T(n) = 2 T(n/2) + 2$

T(2) = 1 T(1) = 0 Ans is (3/2)* n - 2 My solution is : T(n) = 2 T(n/2) + 2 T(n) = 4 T(n/4) + 4 T(n) = 8 T(n/8) + 6 T(n)=(2^k)T(n/2^k) + 2k where k = log(n) ..... in base 2 as n/(2^k) = 1 for T(1) I don't how to solve this type of question to…
Pygirl
  • 199
5
votes
5 answers

difference of recursive equations

Lets have two recursive equations: \begin{align} f(0) &= 2 \\ f(n+1) &= 3 \cdot f(n) + 8 \cdot n \\ \\ g(0) &= -2 \\ g(n+1) &= 3 \cdot g(n) + 12 \end{align} We want a explicit equation for f(x) - g (x). I firstly tried to do in manually for first…
5
votes
0 answers

How to solve the recurrence $T(n) = T(n-2) + log(n)$?

How do I solve the recurrence $$T(n) = T(n-2) + \log(n)$$ with the condition that $T(n) = O(1)$ for $n \leq 2$? I started by using an iterative method $$T(n-2) = T(n - 4) + \log(n-2)$$ then substituting this into the first equation, we find $$T(n)…
4
votes
2 answers

How to solve recursion?

I have tried to solve some recursion: $$f_n = \frac{2n-1}{n}f_{n-1} - \frac{n-1}{n} f_{n-2} + 1, \quad f_0 = 0, f_1 = 1$$ I would like to use a generating function: $$F(x) = \sum_{n=0}^{\infty}f_nx^n$$ Then: $F(x) = f_0 + f_1x +…
xawey
  • 163
4
votes
2 answers

Definition by Recursion: why is the existence part not (almost) obvious?

I saw the following statement. Let $H$ be a set, let $e\in H$ and let $k:H\rightarrow H$ be a function. Then there is a unique function $f:\mathbb{N}\rightarrow H$ such that $f(1)=e$, and that $f\circ s=k\circ f$. (where…
4
votes
3 answers

Asymptotic bounds of $T(n) = T(n/2) + T(n/4) + T(n/8) + n$

This problem is given in "Introduction to Algorithms", by Thomas H. Cormen. I have the answer to it, but I don't understand it. The answer is, $T(n) = \Theta(n)$. It would be really good if you can explain it using recursion tree.
4
votes
1 answer

Prove a function is primitive recursive

Help me please $f(x)=x+a$, where $a$ is a constant.
user58222
  • 151
4
votes
1 answer

Solving the recursive Equation $T(n) = 1 + \frac{2}{n} \sum_{i=1}^{n-2}T(i)$

I have the recursive Equation $$ T(n) = \begin{cases} 0 & \text{for } n = 0,\\ 1 & \text{for } 0 < n \leq 2,\\ \displaystyle 1 + \frac{2}{n} \sum_{i=1}^{n-2} T(i) &\text{else.} \end{cases} $$ Now I want to solve it for large…
4
votes
2 answers

HOW do you refactor a recursive function into a single equation

I have an initial equation which is very simple: answer1 = 0*2+2 But it is recursive such that: answer2 = answer1*2+2 answer3 = answer2*2+2 answer4 = answer3*2+2 How would I go about writing that as a single equation so I can determine what Answer…
Suamere
  • 166
4
votes
1 answer

Is recursion a type of iteration?

From what I understand, in simple terms, The definition of iteration : The act of repeating a process The definition of recursion : The act of repeating smaller process of the same problem It these definitions aren't too far fetched, it looks to…
3
votes
1 answer

constructive proof of solution for this recursive formula

The two conditions $$\frac{p_{\mathrm{up}}(n)}{p_{\mathrm{down}}(n+1)}=c \quad \text{and} \quad p_{\mathrm{up}}(n)+p_{\mathrm{down}}(n)=1$$ lead to $p_{\mathrm{up}}=\frac{c}{c+1}$ and $p_{\mathrm{down}}= \frac{1}{c+1}$. Also…
kyra
  • 257
3
votes
1 answer

Determining the effective tax rate in a tax on tax situation

There are taxation situations where the taxable amount includes the tax calculated on the taxable amount (e.g. this is a recursive calculation, as follows)... Iteration Taxable Amount Tax per iteration 0 $100,000,000.00 $5,000,000.00 1 …
1
2 3
12 13