Question: For the following: get-maximum(list): maximum = -infinity for i = 0 to length(list) - 1: if maximum < list[i]: maximum = list[i] return maximum we

For the following:

get-maximum(list): maximum = -infinity for i = 0 to length(list) - 1: if maximum < list[i]: maximum = list[i] return maximum

we are considering the number of times a value is assigned to "maximum".

1. What is the number of times (average case) that "maximum" is assigned a value for "get-maximum"? Make sure to indicate the probability distribution and sample space clearly as part of your answer, and include all work.

2. What is the number of times (best case) that "maximum" is assigned a value for "get-maximum"? Make sure to include all work.

3. What is the number of times (worst case) that "maximum" is assigned a value for "get-maximum"? Make sure to include all work.

Note that "list" contains only natural numbers, with no duplicates.

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!