Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
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) xStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started