Introduction to Algorithms
Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
bartleby

Concept explainers

Question
Book Icon
Chapter 8, Problem 1P

(a)

Expert Solution
Check Mark
Program Plan Intro

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

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)

Expert Solution
Check Mark
Program Plan Intro

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

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)

Expert Solution
Check Mark
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.

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)

Expert Solution
Check Mark
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 .

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)

Expert Solution
Check Mark
Program Plan Intro

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

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)

Expert Solution
Check Mark
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 .

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
Python - Need help! How do I have an input in turtle to display my name below the circle it draws and another input to display my age written below that? Code: import turtlebackground = "#FFFFFF" def draw_circle(radius, line_color, fill_color): my_turtle.color(line_color) my_turtle.fillcolor(fill_color) my_turtle.begin_fill() my_turtle.circle(radius) my_turtle.end_fill() def move_turtle(x, y): my_turtle.penup() my_turtle.goto(x, y) my_turtle.pendown() turtle.done()
Need help fixing my python code! Images attached on the required modficications I dont know how to do. Simpler the better.Code: (in images)
Answer all of the questions with steps by step explanation to every question.
Knowledge Booster
Background pattern image
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