Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

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

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

Students explore these related Databases questions

Question

n + 3 1 k = 1 n ( x k ) 2 = 0 ; Solve for

Answered: 3 weeks ago