Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

50. It can be shown that \({C_B}\)the average number of comparisons made by the quick sort algorithm (described in preamble to Exercise 50 in Section 5.4), when sorting \(n\)elements in random order, satisfies the recurrence relation\({C_n} = n + 1 + \frac{2}{n}\sum\limits_{k = 0}^{n - 1} {{C_k}} \)

for \(n = 1,2, \ldots \), with initial condition \({C_0} = 0\)

a) Show that \(\left\{ {{C_n}} \right\}\)also satisfies the recurrence relation \(n{C_n} = (n + 1){C_{n - 1}} + 2n\)for \(n = 1,2, \ldots \)

b) Use Exercise 48 to solve the recurrence relation in part (a) to find an explicit formula for \({C_n}\)

Short Answer

Expert verified

(a) Thus, it is verified that Cnsatisfies the recurrence relation nCn=(n+1)Cn-1+2n

(b) Thus, the result isCn=2(n+1)i=1n1i+1

Step by step solution

Achieve better grades quicker with Premium

  • Unlimited AI interaction
  • Study offline
  • Say goodbye to ads
  • Export flashcards

Over 22 million students worldwide already upgrade their learning with Vaia!

01

Linear Homogeneous Recurrence Relations with Constant Coefficients definition

Suppose that\(\left\{ {{a_n}} \right\}\)satisfies the linear non-homogeneous recurrence relation

\({a_n} = {c_1}{a_{n - 1}} + {c_2}{a_{n - 2}} + \cdots + {c_k}{a_{n - k}} + F(n),\)Where\({c_1},{c_2}, \ldots ,{c_k}\)are real numbers, and

\(F(n) = \left( {{b_f}{n^t} + {b_{f - 1}}{n^{t - 1}} + \cdots + {b_1}n + {b_0}} \right){s^n},\)Where\({b_0},{b_1}, \ldots ,{b_t}\)and\(s\)are real numbers.

When\(s\)is not a root of the characteristic equation of the associated linear homogeneous recurrence relation, there is a particular solution of the form\(\left( {{p_t}{n^t} + {p_{t - 1}}{n^{t - 1}} + \cdots + {p_{1n}} + {p_0}} \right){s^n}\)

When\(s\)a root of this characteristic equation and its multiplicity is is\(m\), there is a particular solution of the form:\({n^m}\left( {{p_t}{n^t} + {p_{t - 1}}{n^{t - 1}} + \cdots + {p_1}n + {p_0}} \right){s^n}.\)

02

Use Recurrence Relations

The result from the previous exercise isf(n)an=g(n)an-1+h(n)n1a0=C, then;an=C+i=1nQ(i)·h(i)g(n+1)Q(n+1),Q(n)=f(1)·f(2)··f(n-1)g(1)·g(2)··g(n)

Cn=n+1+2nk=0n-1CkC0=0

(a) Let n1

\(\begin{array}{l}n{C_n} - (n + 1){C_{n - 1}} = n{C_n} - (n - 1){C_{n - 1}} - 2{C_{n - 1}}\\n{C_n} - (n + 1){C_{n - 1}} = n\left( {n + 1 + \frac{2}{n}\sum\limits_{k = 0}^{n - 1} {{C_k}} } \right) - (n - 1)\left( {(n - 1) + 1 + \frac{2}{{(n - 1)}}\sum\limits_{k = 0}^{(n - 1) - 1} {{C_k}} } \right) - 2{C_{n - 1}}\\n{C_n} - (n + 1){C_{n - 1}} = {n^2} + n + 2\sum\limits_{k = 0}^{n - 1} {{C_k}} - (n - 1)\left( {n + \frac{2}{{n - 1}}\sum\limits_{k = 0}^{n - 2} {{C_k}} } \right) - 2{C_{n - 1}}\\n{C_n} - (n + 1){C_{n - 1}} = {n^2} + n + 2\sum\limits_{k = 0}^{n - 1} {{C_k}} - \left( {{n^2} - n} \right) - 2\sum\limits_{k = 0}^{n - 2} {{C_k}} - 2{C_{n - 1}}\\n{C_n} - (n + 1){C_{n - 1}} = 2n + 2\sum\limits_{k = 0}^{n - 1} {{C_k}} - 2\sum\limits_{k = 0}^{n - 1} {{C_k}} \\n{C_n} - (n + 1){C_{n - 1}} = 2n + 0\\n{C_n} - (n + 1){C_{n - 1}} = 2n\end{array}\)

We then obtained\(n{C_n} - (n + 1){C_{n - 1}} = 2n\), which equivalent is with:

\(n{C_n} = (n + 1){C_{n - 1}} + 2n\).

03

Use Recurrence Relations for part (b)

(b).

Equation is:\(n{C_n} = (n + 1){C_{n - 1}} + 2n{C_0} = 0\)

Since\(f(n){a_n} = g(n){a_{n - 1}} + h(n)\)and\({a_0} = C\)(in general):

\(f(n) = ng(n) = n + 1h(n) = 2nC = 0\)

Let us first determine\(Q(n) = \frac{{f(1) \cdot f(2) \cdot \ldots \cdot f(n - 1)}}{{g(1) \cdot g(2) \cdot \ldots \cdot g(n)}}\)

\(\begin{array}{c}Q(n) = \frac{{f(1) \cdot f(2) \cdot \ldots \cdot f(n - 1)}}{{g(1) \cdot g(2) \cdot \ldots \cdot g(n)}}\\ = \frac{{1 \cdot 2 \cdot \ldots \cdot (n - 1)}}{{2 \cdot 3 \cdot \ldots \cdot (n + 1)}}\\ = \frac{1}{{n \cdot (n + 1)}}\end{array}\)

Then we obtain:

\(\sum\limits_{i = 1}^n Q (i)h(i) = \sum\limits_{i = 1}^n {\frac{{2i}}{{i \cdot (i + 1)}}} = \sum\limits_{i = 1}^n {\frac{2}{{i + 1}}} \)

\(\sum\limits_{i = 1}^n Q (i)h(i) = \sum\limits_{i = 1}^n {\frac{{2i}}{{i \cdot (i + 1)}}} = \sum\limits_{i = 1}^n {\frac{2}{{i + 1}}} \)

Using the result of the previous exercise, we then obtain:

\(\begin{array}{c}{C_n} = \frac{{C + \sum\limits_{i = 1}^n Q (i) \cdot h(i)}}{{g(n + 1)Q(n + 1)}}\\{C_n} = \frac{{0 + \sum\limits_{i = 1}^n {\frac{2}{{i + 1}}} }}{{(n + 2) \cdot \frac{1}{{(n + 1)(n + 2)}}}}\\{C_n} = \frac{{\sum\limits_{i = 1}^n {\frac{2}{{i + 1}}} }}{{\frac{1}{{n + 1}}}}\\{C_n} = (n + 1)\sum\limits_{i = 1}^n {\frac{2}{{i + 1}}} \\{C_n} = 2(n + 1)\sum\limits_{i = 1}^n {\frac{1}{{i + 1}}} \end{array}\)

Thus, the result is\({C_n} = 2(n + 1)\sum\limits_{i = 1}^n {\frac{1}{{i + 1}}} \)

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Suppose that the function \(f\) satisfies the recurrence relation \(f(n) = 2f(\sqrt n ) + 1\) whenever \(n\) is a perfect square greater than\(1\)and\(f(2) = 1\).

a) Find\(f(16)\).

b) Give a big- \(O\) estimate for\(f(n)\). (Hint: Make the substitution\(m = \log n\)).

Find the solution of the recurrence relation an=3an-1-3an-2+an-3+1ifa0=2,a1=4anda2=8

Use generating functions (and a computer algebra package, if available) to find the number of ways to make change for $1 using

a) dimes and quarters.

b) nickels, dimes, and quarters.

c) pennies, dimes, and quarters.

d) pennies, nickels, dimes, and quarters.

A sequence \({a_1},{a_2},.....,{a_n}\) is unimodal if and only if there is an index \(m,1 \le m \le n,\) such that \({a_i} < {a_i} + 1\) when \(1{1 < i < m}\) and \({a_i} > {a_{i + 1}}\) when \(m \le i < n\). That is, the terms of the sequence strictly increase until the \(m\)th term and they strictly decrease after it, which implies that \({a_m}\) is the largest term. In this exercise, \({a_m}\) will always denote the largest term of the unimodal sequence \({a_1},{a_2},.....,{a_n}\).

a) Show that \({a_m}\) is the unique term of the sequence that is greater than both the term immediately preceding it and the term immediately following it.

b) Show that if \({a_i} < {a_i} + 1\) where \(1 \le i < n\), then \(i + 1 \le m \le n\).

c) Show that if \({a_i} > {a_{i + 1}}\) where \(1 \le i < n\), then \(1 \le m \le i\).

d) Develop a divide-and-conquer algorithm for locating the index \(m\). (Hint: Suppose that \(i < m < j\). Use parts (a), (b), and (c) to determine whether \(((i + j)/2) + 1 \le m \le n,\) \(1 \le m \le ((i + j)/2) - 1,\) or \(m = ((i + j)/2)\)

Prove Theorem 4.

See all solutions

Recommended explanations on Math Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free