Question: Computer algorithm question: (a), pretend a,b,c are in an array (in slots E[0], E[1], E[2]), and have your algorithm return the INDEX (namely 0, 1,

Computer algorithm question:

(a), pretend a,b,c are in an array (in slots E[0], E[1], E[2]), and have your algorithm return the INDEX (namely 0, 1, or 2) of the median.

Your algorithm should take care not to destroy the array.

(c) How many comparisons are necessary in the worst case to find the median of three numbers? Justify your answer. Optimality argument is required.

(e): The parameters of the problem have simplified things so that there are no ties, and your answers to the first four parts can assume that this is the case. Assume for a moment that ties are allowed. If your (unwritten, and you do NOT have to write a new one) algorithm were to discover that the first two entries you compared were equal to each other, what can you say about the median of the entries in this 3-element array?

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!