Questions tagged [recursive-algorithms]

Questions dealing with recursive algorithms. Their analysis often involves recurrence relations, which have their own tag.

1240 questions
104
votes
1 answer

Can we remove any prime number with this strange process?

This is a little algorithm I made today, which may appear to be quite complex so I will start with an example. The process goes as follows: Start with the first prime number, $2$. From $2$, add the next prime number ($3$) to get $2+3=5$. There are…
17
votes
6 answers

How to solve this recurrence relation? $f_n = 3f_{n-1} + 12(-1)^n$

How to solve this particular recurrence relation ? $$f_n = 3f_{n-1} + 12(-1)^n,\quad f_1 = 0$$ such that $f_2 = 12, f_3 = 24$ and so on. I tried out a lot but due to $(-1)^n$ I am not able to solve this recurrence? Any help will be highly…
16
votes
2 answers

Could someone tell me how large this number is?

Context: If you guys didn't know, I'm running a nice little contest to see who can program the largest number. More specific rules if you are interested may be found in my chat room (click here to join). If you are entering, do note that I am…
Simply Beautiful Art
  • 71,916
  • 11
  • 112
  • 250
15
votes
2 answers

Algorithm to calculate rating based on multiple reviews (using both review score and quantity)

First of all I must state that I am not a mathematician, so please correct me if I use wrong terminology. I am building a web application which needs to calculate the rating for each entity based on both the quantity and score of the reviews for…
15
votes
4 answers

How does FFT work?

For five years I tried to understand how Fourier transform works. Read a lot of articles, but nobody could explain it in simple terms. Two weeks ago I stumbled upon the video about a 100 years old machine that calculates Fourier series mechanically:…
11
votes
3 answers

How to tell if a particular number will survive in this sieve?

I was asked this in an interview. We have people numbered from one to infinity: $$1, 2, 3, 4, 5, 6, 7, 8, \dotsc\,.$$ In first pass every 2nd person is killed, so we have $$1, 3, 5, 7, 9, 11,\dotsc$$ remaining. In next pass every 3rd remaining…
Oliver Blue
  • 365
  • 2
  • 10
10
votes
3 answers

Using Horner's Method

I'm trying to evaluate a polynomial recursively using Horner's method. It's rather simple when I have every value of $x$ (like: $x+x^2+x^3...$), but what if I'm missing some of those? Example: $-6+20x-10x^2+2x^4-7x^5+6x^7$. I would also appreciate…
Chandra
  • 103
  • 1
  • 1
  • 4
10
votes
1 answer

Let $X$ be a random variable, $\frac{\mathbb{E}[e^{sX}-e^{tX}]}{s-t}$ for $s \approx t$. As

Question Let $X$ be a random variable for which we only have the value of its Moment Generating Function $M_X$ on a discrete set of points, I am looking for a stable method to compute: $$\frac{M_X(s) -…
10
votes
2 answers

Numerical method for finding the square-root.

I found a picture of Evan O'Dorney's winning project that gained him first place in the Intel Science talent search. He proposed a numerical method to find the square root, that gained him $100,000 USD. Below are some links of pictures of the poster…
10
votes
5 answers

Worst case analysis of MAX-HEAPIFY procedure .

From CLRS book for MAX-HEAPIFY procedure : The children's subtrees each have size at most 2n/3 - the worst case occurs when the last row of the tree is exactly half full I fail to see this intuition for the worst case scenario . Can some one…
Geek
  • 2,169
  • 9
  • 33
  • 45
10
votes
4 answers

Solving a Recurrence Relation/Equation, is there more than 1 way to solve this?

1) Solve the recurrence relation $$T(n)=\begin{cases} 2T(n-1)+1,&\text{if }n>1\\ 1,&\text{if }n=1\;. \end{cases}$$ 2) Name a problem that also has such a recurrence relation. The answer I got somewhere is here: Here $T_0=0,T_n-2T_{n-1}=1$ for…
user1189352
  • 203
  • 2
  • 4
9
votes
6 answers

Non-literal applications of "Shortest Path" algorithm?

It's obvious that it's used in stuff like Google Maps, but what are some more metaphorical applications where you're minimizing the path between nodes (which can represent anything)
JackOfAll
  • 4,385
  • 9
  • 45
  • 70
9
votes
3 answers

Karatsuba vs. Schönhage-Strassen for multiplication of polynomials

I am wondering how to most effectively multiply two polynomials with several $100$'s of coefficients, each coefficient having $1000$-$2000$ decimal digits. I know Schönhage-Strassen begins to outperform Karatsuba between $10,000$ and $40,000$…
9
votes
3 answers

Repertoire method for solving recursions

I am trying to solve this four parameter recurrence from exercise 1.16 in Concrete Mathematics: \[ g(1)=\alpha \] \[ g(2n+j)=3g(n)+\gamma n+\beta_j \] \[ \mbox{for}\ j=0,1\ \mbox{and}\ n\geq1 \] I have assumed the closed form to be: $$g(n) =…
9
votes
3 answers

Computing how many distinct digital products are below $10^n$

Given a number $n$, its digital product is the product of its digit. So the digital product of $15$ is $1\times 5=5$, and the digital product of $760$ is $0$, etc. I recently saw a nice video on Numberphile where they discussed persistence, namely…
Asaf Karagila
  • 370,314
  • 41
  • 552
  • 949
1
2 3
82 83