Question: Perform an experimental analysis of the three algorithms prefix average1, prefix average2, and prefix average3, from Section 3.3.3. Visualize their running times as a function

Perform an experimental analysis of the three algorithms prefix average1, prefix average2, and prefix average3, from Section 3.3.3. Visualize their running times as a function of the input size with a log-log chart.

Perform an experimental analysis of the three algorithms prefix average1, prefix average2,and prefix average3, from Section 3.3.3. Visualize their running times as afunction of the input size with a log-log chart. 3 4 1

3 4 1 def prefix_averagel(s): 2 "Return list such that, for all j, A[i] equals average of S[0], ..., S[i].** n = len() A = [0] *n # create new list of n zeros 5 for j in range(n): total = 0 # begin computing S[0] + ... + S[] 7 for i in rangeli + 1): 8 total += 50 A[i] = total / (+1) #record the average 10 return A Code Fragment 3.2: Algorithm prefix_averagel. 6 9 1 def prefix-average2(S): 2 ***"Return list such that, for all j, A[j] equals average of S[0], ..., S[i]." 3 n = len(S) 4 A = [0] *n #create new list of n zeros 5 for j in range(n): A[i] = sum(S[0:j+1]) / (+1) #record the average 7 return A Code Fragment 3.3: Algorithm prefix_average2. 6

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!