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)

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
A cylinder of diameter 10 cm rotates concentrically inside another hollow cylinder of inner diameter 10.1 cm. Both cylinders are 20 cm long and stand with their axis vertical. The annular space is filled with oil. If a torque of 100 kg cm is required to rotate the inner cylinder at 100 rpm, determine the viscosity of oil. Ans. μ= 29.82poise
Make the following game user friendly with GUI, with some simple graphics The following code works as this: The objective of the player is to escape from this labyrinth. The player starts at the bottom left corner of the labyrinth. He has to get to the top right corner of the labyrinth as fast he can, avoiding a meeting with the evil dragon. The player can move only in four directions: left, right, up or down. There are several escape paths in all labyrinths. The player’s character should be able to moved with the well known WASD keyboard buttons. If the dragon gets to a neighboring field of the player, then the player dies. Because it is dark in the labyrinth, the player can see only the neighboring fields at a distance of 3 units.  Cell Class: public class Cell { private boolean isWall; public Cell(boolean isWall) { this.isWall = isWall; } public boolean isWall() { return isWall; } public void setWall(boolean isWall) { this.isWall = isWall; } @Override public String toString() {…
Please original work What are four of the goals of information lifecycle management think they are most important to data warehousing, Why do you feel this way, how dashboards can be used in the process, and provide a real life example for each. Please cite in text references and add weblinks
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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education