Question

1.23 The median of an ordered set is an element such that the number of elements less than the median is within one of the n

Example 1.9:

Finally, we combine the cases in which K is in the array and is not in the array. Letq be the probability that K is in the ar

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a)

Algorithm->

median(a,b,c)

if a>b and a<c then return a

if a>c and a<b then return a

if b>a and b<c then return b

if b>c and b<a then return b

return c

b) Dn = {a,b,c} in any order

c) assuming two comparison in one statements, if c is median, it requires 8 comparisons

d) 3 comparison required in minimum

if (a > b)

    {

        if (b > c)

            return b;

        else if (a > c)

            return c;

        else

            return a;

    }

    else

    {

        // Decided a is not greater than b.

        if (a > c)

            return a;

        else if (b > c)

            return c;

        else

            return b;

    }

Add a comment
Know the answer?
Add Answer to:
Example 1.9: 1.23 "The median of an ordered set is an element such that the number...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT