Introduction To Algorithms, Third Edition (international Edition)
Introduction To Algorithms, Third Edition (international Edition)
3rd Edition
ISBN: 9780262533058
Author: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein
Publisher: TRILITERAL
bartleby

Concept explainers

Question
Book Icon
Chapter 8, Problem 1P

(a)

Program Plan Intro

To prove that exactly n! leaves are labeled 1/n! and that the rest are labeled 0.

(a)

Expert Solution
Check Mark

Explanation of Solution

The input array has distinct elements and each element is equally likely so the distribution is uniformly supported on the array.

As the array has n elements then the probability of each element occurs as 1/n! and the corresponding to different leaf as the program needs to be distinguishes between all the elements.

Since, there are distinct n elements so thepermutation of the leaf nodes is exactly n! .

(b)

Program Plan Intro

To shows D(T)=D(LT)+D(RT)+k where D(T) is the external path length of tree T .

(b)

Expert Solution
Check Mark

Explanation of Solution

Suppose the tree T then the depth of particular elements of LT is one less than the depth of the tree so the D(T) of the tree is defined as follows:

  D(T)=lL(T)DT(l).lL(T)DT(l)=lL(T)DT(l)+lR(T)DT(l).D(T)=lL(LT)(DTL(l)+1)+lL(RT)(DTR(l)+1).D(T)=lL(LT)DTL(l)+lL(RT)DRT(l)+k.D(T)=D(LT)+D(RT)+k.

Since the minimum length of the left leaf and the minimum length of the right leaf are equals to the length of the tree there is another variable k which defines the constant increasing in the path defined in the minimum path of the length.

Therefore, D(T)=D(LT)+D(RT)+k.

(c)

Program Plan Intro

To show that d(k)=min{d(i)+d(ki)+k} where d(k) is the minimum value of D(T) overall decision tree T.

(c)

Expert Solution
Check Mark

Explanation of Solution

Suppose a tree T having leaves node k, LT and RT be minimum length path of left and right leaves then the equation of the tree is defined as follows:

  D(T)=d(k).

Suppose the minimum path length equation of the tree as follows:

  D(T)=D(LT)+D(RT)+k.

Now, suppose the LT have i0 number of leaves then combining the both above equations it get the following:

  d(k)=d(i)+d(ki)+k.

For the minimum external path length the value of the equation is consider as minimum value of the i value of the d(k) so the equation will as follows:

  d(k)=min{d(i)+d(ki)+k}.

(d)

Program Plan Intro

To show that the function ilgi+(ki)lg(ki) is minimum at i=k/2 for a given value of k>1 and 1ik1 .

(d)

Expert Solution
Check Mark

Explanation of Solution

Suppose i is a continuous variable and it finds the critical points using derivatives of the tree equation d(k)=min{d(i)+d(ki)+k} now the taking the general term of the tree the equation will be d(k)=d(i)+d(ki)+k .

Suppose it picks the two sub-trees of approx. equal sizes then the depth of the tree is equals to lgk contributing each level k therefore the total external path length is at least klgk .

Suppose the tree equation d(k)=d(i)+d(ki)+k .

Taking the log on both sides with derivate of the equation.

  1ln(2)+lg(i)+1ln(2)lg(k1)=2ln(2)+lgi(ki).

Putting the value iki=0 .

  iki=22ln(2)=2elg(e2)=e2.

As (1+e2)i=k .

  i=k1+e2 .

Therefore, the equation ilgi+(ki)lg(ki) is minimum if k=k/2 .

(e)

Program Plan Intro

To show that D(TA)=Ω(n!lg(n!)) and computes the average-case time to sort n -elements is Ω(nlgn) .

(e)

Expert Solution
Check Mark

Explanation of Solution

Suppose that a tree with k leaves needs to have external length klgk and that a sorting tree needs at least n! tree, a sorting tree must have external tree of length at least n!lg(n!) .

The average-case is the situation in which the algorithm computes the execution and given the result in moderate time and moderate conditions.

Since the average-case run time is the depth of a leaf weighted by the probability of that leaf being the one that occurs.

Therefore, the running time is n!lg(n!)/n!=lg(n!)Ω(nlgn) .

(f)

Program Plan Intro

To show that for any randomized comparison sort B , there is a deterministic comparison sort A whose expected number of comparisons is no more than those made by B .

(f)

Expert Solution
Check Mark

Explanation of Solution

The expected running time is the average over all possible results from the random bits. The equation of the tree is defined as follows: n!lg(n!)/n!=lg(n!) .

The comparisons sort of B has the randomness that has higher value than the deterministic comparisons of A. The random sorting algorithm uses the partition of the array and uses the random sorting values for the dividing the array.

The possible fixing of the randomness resulted in a higher runtime, the average would have to be higher than the other so comparisons sort of B has higher value.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
I need to develop and run a program that prompts the user to enter a positive integer n, and then calculate the value of n factorial n! = multiplication of all integers between 1 and n, and print the value n! on the screen. This is for C*.
I need to develop and run a C* program to sum up integers from 1 to 100, and print out the sum value on the screen. Can someone help please?
Given the schema below for the widgetshop, provide a schema diagram. Schema name Attributes Widget-schema Customer-schema (stocknum, manufacturer, description, weight, price, inventory) (custnum, name, address) Purchased-schema (custnum, stocknum, pdate) Requestedby-schema (stocknum, custnum) Newitem-schema (stocknum, manufacturer, description) Employee-schema (ssn, name, address, salary) You can remove the Newitem-schema (red).
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Fundamentals of Information Systems
Computer Science
ISBN:9781305082168
Author:Ralph Stair, George Reynolds
Publisher:Cengage Learning