Question: Java Question: Disk space AnalysisPlease advise the code in Java 7 or 8 2. Disk Space Analysis A company is performing an analysis on the
Java Question: Disk space AnalysisPlease advise the code in Java 7 or 8





2. Disk Space Analysis A company is performing an analysis on the computers at its main office. The computers are spaced along a single row. For each group of contiguous computers of a certain length, that is, for each segment, determine the minimum amount of disk space available on a computer. Return the maximum of these values as your answer. Example n = 4, the number of computers space=[8, 2, 4, 6] x = 2, the segment length The free disk space of computers in each of the segments is [8, 2], [2, 4], [4, 6]. The minima of the three segments are [2, 2, 4]. The maximum of these is 4. Function Description Complete the function segment in the editor below. segment has the following parameter(s): int x: the segment length to analyze int space[n]: the available hard disk space on each of the computers Returns: int: the maximum of the minimum values of available hard disk space found while analyzing the computers in segments of length x Constraints . Input Format for Custom Testing The first line contains an integer, x, the segment length for analyzing the row of computers. The second line contains an integer, n, the size of the array space. Each line i of the n subsequent lines (where 0 i Input Format for Custom Testing The first line contains an integer, x, the segment length for analyzing the row of computers. The second line contains an integer, n, the size of the array space. Each line i of the n subsequent lines (where 0 i Sample Case 1 Sample Input STDIN 231 LL 1 1 1 Function length of segments x = 2 size of space n = 3 space = [1, 1, 1] Sample Output Explanation The segments of size x = 2 are [1, 1] and [1, 1]. The minimum value for both segments is 1. The maximum of these values is 1. Sample Case 2 Sample Input STDIN 3 00 NUU 5 2 5 6 8 4 Function length of segments x = 3 size of space n = 5 space= [2, 5, 4, 6, 8] Sample Output Explanation The segments of size x = 3 are [2, 5, 4], [5, 4, 6], and [4, 6, 8]. The respective minimum values are 2, 4, and 4. The maximum of these values is 4. 4
Step by Step Solution
3.33 Rating (147 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
