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
KNN, decision tree: (Machine learning) Please ans question B and C specifically-  6. Consider a binary classification problem using 1-nearest neighbors with the Euclidean distance metric. We have N 1-dimensional training points x(1), x(2), . . . x(N ) and corresponding labelsy(1), y(2), . . . y(N ) with x(i ) ∈ R and y(i ) ∈ {0, 1}. Assume the points x(1), x(2), . . . x(N ) are in ascending order by value. If there are ties during the 1-NN algorithm, we break ties by choosing the labelcorresponding to the x(i ) with lower value.  (a) Is it possible to build a decision tree that behaves exactly the same as the1-nearest neighbor classifier? Assume that the decision at each node takes the form of “ x ≤ t or x > t,” where t ∈R.◯ Yes◯ NoIf your answer is yes, please explain how you will construct the decision tree. If your answer is no,explain why it’s not possible.  (b) Let’s add a dimension! Now assume the training points are 2-dimensionalwhere x(i ) = ( x( 1i), x( 2i )) ∈R2 and…
Correct answer will be upvoted else Multiple Downvoted. Computer science. Polycarp accepts that a bunch of k sections is acceptable in case there is a fragment [li,ri] (1≤i≤k) from the set, with the end goal that it converges each portion from the set (the convergence should be a point or section). For example, a bunch of 3 fragments [[1,4],[2,3],[3,6]] is acceptable, since the portion [2,3] meets each section from the set. Set of 4 fragments [[1,2],[2,3],[3,5],[4,5]] isn't acceptable.    Polycarp ponders, what is the base number of sections he has to erase so the remaining portions structure a decent set?    Input    The primary line contains a solitary integer t (1≤t≤2⋅105) — number of experiments. Then, at that point, t experiments follow.    The primary line of each experiment contains a solitary integer n (1≤n≤2⋅105) — the number of portions. This is trailed by n lines depicting the fragments.    Each section is portrayed by two integers l and r (1≤l≤r≤109) — coordinates of the…
Suppose we have the following undirected graph, and we know that the two bolded edges (B-E and G-E) constitute the global minimum cut of the graph. 1. If we run the Karger’s algorithm for just one time to find the global minimum cut, what is the probability for the algorithm to find the minimum cut correctly? Please show your reasoning process. 2. How many times do we need to run the Karger’s algorithm if we want to guarantee that the probability of success is greater than or equal to 0.95, by “success” we mean that there is at least one time the Karger’s algorithm correctly found the minimum cut. Please show your reasoning process. [You do not have to work out the exact value of a logarithm]
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