Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Give pseudocode of a comparison-based algorithm that outputs the maximum of f

ID: 3705086 • Letter: 1

Question

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

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

Explanation / Answer

If you post more than 1 question, as per chegg guidelines I have to solve only first question.

Ques 1.

function maximum(x1, x2, x3, x4)

BEGIN

    // if x1 is maximum

    if x1 > x2 and x1 > x3 and x1 > x4

         return x1

    // if x2 is maximum

    else if x2 > x1 and x2 > x3 and x2 > x4

         return x2

    // if x3 is maximum

    else if x3 > x1 and x3 > x2 and x3 > x4

         return x3

    // if x4 is maximum

    else

         return x4


END