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
The subset sum problem is defined as follows: SUBSETSUM = {(a1, a2,...,am; b) : m,a1, a2, ...,am; b are integers and 3IC {1,2, ..., m} such that Eier a; =b}. Assume you have a polynomial-time algorithm A that decides, for any input sequence (a1, a2, ...,am, b), whether or not (a1, a2, ...,am, b) E SUBSETSUM. Note that this algorithm only returns YES or NO; it does not return anything else. Design a polynomial-time algorithm B that takes an arbitrary sequence (a1, az, ..., am, b) as input. • If (a1, a2, ...,am; b) E SUBSETSUM, then B returns a subset I of {1,2, ..., m} such that Eier a; = b. If (a1, a2, ..., am, b) & SUBSETSUM, then B returns NO. Your algorithm B may use algorithm A as a black box. As always, justify your answer.
Question 8 Greedy best-fırst search is equivalent to A* search with all step costs set to 0. O True O False Question 9 If you had implemented Uniform Cost Search (the graph search version) in Programming Assignment 1, it would have found an optimal solution. (You may assume that the path costs are kept with the nodes on the frontier and explored lists and checked when comparing newly generated states to what has been seen before.) O True O False Question 10 A* search with an admissible heuristic always expands fewer nodes than depth-first search. O True O False
Algebraic Preis’ AlgorithmAlgorithm due to Preis provides a different way to solve the maximal weightedmatching problem in a weighted graph. The algorithm consists of the followingsteps.1. Input: A weighted graph G = (V, E, w)2. Output: A maximal weighted matching M of G3. M ← Ø4. E ← E5. V ← V6. while E = Ø7. select at random any v ∈ V8. let e ∈ E be the heaviest edge incident to v9. M ← M ∪ e10. V ← V {v}11. E ← E \ {e and all adjacent edges to e} show two ways of implementing this algorithm in Python
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