Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given an array a of n numbers, consider the problem of computing the average of the first i numbers, for i ranging from 0 to

image text in transcribed

Given an array a of n numbers, consider the problem of computing the average of the first i numbers, for i ranging from 0 to n - 1. That is, compute the array b of length n, where bi] Let us assume that all numbers are integer, and so averages are computed with no fractional part; for example. (2+5+1)/3 2. We call b the array of prefix averages of a. Write a program to compute the maximum of the prefix averages of a set of input numbers. Call your program MaxPrefixAverage. The input consists of two lines. The first line contains a single positive integer n, and the second line contains n integers separated by spaces single integer. . The output is a Your program should use O(1) memory; in particular, it may not use an array of length proportional to n. For example, if the input is 3 17 4 6 then the correct output is 4 This is because the prefix averages are: 3/1 3, (3 + 1)/2-2, (3 + 1 + 7)/3 = 3, (3+1+7+4)/4-3, and (3+1+7+4+6)/5 - 4. The maximum of these numbers is

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

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions

Question

Grainy images are often a result of _ _ _ _ _ _ . visual media

Answered: 1 week ago

Question

=+and reduction in force, and intellectual property.

Answered: 1 week ago