/* Java class that includes methods for determining the maximum segment sum ** of an array (or segment thereof) containing int values. ** ** Author: R. McCloskey and < student's name > ** Date: January 2020 */ public class MaxSegSumViaRec implements MaxSegSum { // instance variables // ------------------ private int maxSum; // result of most recent call to maxSegSum() private long workMeasure; // # calls and loop iterations since reset() // constructor // ----------- public MaxSegSumViaRec() { // STUB! } // observers // --------- public int maxSegSumVal() { return -1; // STUB! } public long measureOfWork() { return workMeasure; } // mutators // -------- public void reset() { workMeasure = 0L; } public int maxSegSum(int[] a) { return maxSegSum(a, 0, a.length); } /* Returns the largest sum among all segments of the given array segment ** (i.e., a[low..high)), using the recursive approach. ** pre: 0 <= low <= high <= a.length */ public int maxSegSum(int[] a, int low, int high) { return -1; // STUB! } // private methods // --------------- /* Returns the largest sum of any prefix of the given array segment. ** Prefixes of the given segment include b[bottom..k) for all k ** satisfying bottom <= k <= top. ** pre: 0 <= bottom <= top <= b.length */ private int maxPrefixSum(int[] b, int bottom, int top) { return -1; // STUB! } /* Returns the largest sum of any suffix of the given array segment. ** Suffixes of the given segment include b[k..top) for all k ** satisfying bottom <= k <= top. ** pre: 0 <= bottom <= top <= b.length */ private int maxSuffixSum(int[] b, int bottom, int top) { return -1; // STUB! } }