Skip to main content
edited tags
Link
Karsten7
  • 27.6k
  • 5
  • 74
  • 135
added 5 characters in body
Source Link
m_goldberg
  • 108.1k
  • 16
  • 104
  • 259

In the book "An Introduction to the Analysis of Algorithms"An Introduction to the Analysis of Algorithms there is a recurrence relation for the number of compares used in Quicksort algorithm: $$ C_N=N+1+\sum_{0≤k≤N-1}\frac{1}{N}(C_k+C_{N−k−1}) $$ (See http://aofa.cs.princeton.edu/10analysis/ for details)

This recurrence relation is already solved in the book: $$ C_N = 2(N+1)H_N - 2N$$$$ C_N = 2(N+1)H_N - 2N,$$ , wherewhere $ H_N $ are harmonic numbers.

Now I'm trying to solve it using MathematicaMathematica:

RSolve[{c[n] == n + 1 + 1/n*Sum[c[k] + c[n - k - 1], {k, 0, n - 1}], 
        c[0] == 0}, c[n], n]

Unfortunately, I can't get a result: RSolveRSolve just pretty prints input and doesn't solve anything.

Is there any way to solve such recurrences using MathematicaMathematica? Are there any other CASes which able to solve it?

In the book "An Introduction to the Analysis of Algorithms" there is a recurrence relation for the number of compares used in Quicksort algorithm: $$ C_N=N+1+\sum_{0≤k≤N-1}\frac{1}{N}(C_k+C_{N−k−1}) $$ (See http://aofa.cs.princeton.edu/10analysis/ for details)

This recurrence relation is already solved in the book: $$ C_N = 2(N+1)H_N - 2N$$ , where $ H_N $ are harmonic numbers.

Now I'm trying to solve it using Mathematica:

RSolve[{c[n] == n + 1 + 1/n*Sum[c[k] + c[n - k - 1], {k, 0, n - 1}], 
        c[0] == 0}, c[n], n]

Unfortunately, I can't get a result: RSolve just pretty prints input and doesn't solve anything.

Is there any way to solve such recurrences using Mathematica? Are there any other CASes which able to solve it?

In the book An Introduction to the Analysis of Algorithms there is a recurrence relation for the number of compares used in Quicksort algorithm: $$ C_N=N+1+\sum_{0≤k≤N-1}\frac{1}{N}(C_k+C_{N−k−1}) $$ (See http://aofa.cs.princeton.edu/10analysis/ for details)

This recurrence relation is already solved in the book: $$ C_N = 2(N+1)H_N - 2N,$$ where $ H_N $ are harmonic numbers.

Now I'm trying to solve it using Mathematica:

RSolve[{c[n] == n + 1 + 1/n*Sum[c[k] + c[n - k - 1], {k, 0, n - 1}], 
        c[0] == 0}, c[n], n]

Unfortunately, I can't get a result: RSolve just pretty prints input and doesn't solve anything.

Is there any way to solve such recurrences using Mathematica? Are there any other CASes which able to solve it?

Source Link

RSolve and a recurrence relation

In the book "An Introduction to the Analysis of Algorithms" there is a recurrence relation for the number of compares used in Quicksort algorithm: $$ C_N=N+1+\sum_{0≤k≤N-1}\frac{1}{N}(C_k+C_{N−k−1}) $$ (See http://aofa.cs.princeton.edu/10analysis/ for details)

This recurrence relation is already solved in the book: $$ C_N = 2(N+1)H_N - 2N$$ , where $ H_N $ are harmonic numbers.

Now I'm trying to solve it using Mathematica:

RSolve[{c[n] == n + 1 + 1/n*Sum[c[k] + c[n - k - 1], {k, 0, n - 1}], 
        c[0] == 0}, c[n], n]

Unfortunately, I can't get a result: RSolve just pretty prints input and doesn't solve anything.

Is there any way to solve such recurrences using Mathematica? Are there any other CASes which able to solve it?