Question: 1. Give pseudocode of a comparison-based algorithm that outputs the maximum of four integers x1, x2, x3, x4. 2. Draw the decision tree of the

1. Give pseudocode of a comparison-based algorithm that outputs the maximum of four integers x1, x2, x3, x4.

2. Draw the decision tree of the algorithm in the style of below, clearly labeling i)each internal node with the comparison ("<") being performed, ii) each edge with a comparison outcome True or False (not done in below figure), and iii) each external node with the maximum found. student submitted image, transcription available below

algorithm Proof: The running time of a comparison-based sorting alg greater than or equal to the height of the decision tree T associated witust gorithm, as described above. (See Figure 8.12.) By the above argume this external node in T must be associated with one permutatico permutation of S must result in a different external node ofT permutations of n objects is ritho decision treo must b with this a above argument, each . The numbees, Thus, T must have at least nl external nodes. By Theorem 2.7, the height of T at least log(n!). This immediately justifies the theorem, because there are at t /2 terms that are greater than or equal to n/2 in the product n!; hence east log(n!) 2 log (3) = 2 log n which is ?(n log n) minimum height (time) x

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!