Question: 2.2: Problem 1.23, page 63 (part a, b, c, d, and plus the additional part E, described below). For part (a), pretend a,b,c are in

2.2: Problem 1.23, page 63 (part a, b, c, d, and plus the additional part E, described below). 2.2: Problem 1.23, page 63 (part a, b, c, d, and plusFor part (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.Of course, your algorithm should take care not to destroy the array. For part (b), the discussion referred to 'after Example 1.9' is on Page 37. For part (c), SUPPORT YOUR ANSWER by drawing the DECISION TREE for the algorithm you described in part (a). [See the end of my Chapter 1 notes for an ilustration of how decision trees should be labelled: DON'T emulate the uninformative format show at the top of page 60 (Figure 1.8). Use ovals for decision nodes, and rectangles for outcome nodes] For part (d), note that an optimality argument is required.(Part (E) of Problem 1.23 is not in the textbook, but answer it anyway :-) Problem 1.23 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. In part (E), 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?

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 number that are greater, assuming no ties. a. Write an algorithm to find the median of three distinct integers a, b, and c. b. Describe D, the set of inputs for your algorithm, in light of the discussion in Sec- tion 1.4.3 following Example 1.9 How many comparisons does your algorithm do in the worst case? On the average? How many comparisons are necessary in the worst case to find the median of three numbers? Justify your answer. c. d

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!