Question: // bigMesa() // locates most massive mesa in an array of integer values // a mesa is a run of equal values // the mass

// bigMesa() // locates most massive "mesa" in an array of integer values // a "mesa" is a run of equal values // the "mass" of a "mesa" is the sum of the values in the mesa // a "mesa" can't have length < MIN_MESA_LENGTH #include "bigMesa.h"

/** * Given an array of nonnegative integers, a mesa is a sequence of at * least MIN_MESA_LENGTH identical values. The length of a mesa is the * number of values in the sequence, and the mass of a mesa is the sum * of the values in the sequence. * * bigMesa() determines the mesa of maximum mass in the array that is * passed into it. bigMesa() reports its results by setting three extern * variables: mesaStart, mesaEnd and mesaMass. * * Pre: A[0:A_SZ - 1] are nonnegative integers. * The caller has declared the following three variables with * external linkage, so they can be accessed by this function: * uint8_t mesaStart * uint8_t mesaEnd * uint32_t mesaMass * * Post: mesaStart = index of first element of most massive mesa * mesaEnd = index of last element of most massive mesa * mesaMass = sum of elements in most massive mesa * All are set to zero if no mesa is found. * * Restrictions: * You may not use a second array. * You MUST use array bracket notation whenever you access an array * element. */ Mesa bigMesa(const uint16_t A[], uint8_t A_SZ) {

// Create a dummy Mesa object to hold final answer; this will be // modified in the code you write below. Mesa possible = {0, 0, 0, 0, false}; // You must write the body of the implementation here; use helper // functions if you like. // Return the updated Mesa object to the caller: return possible; }

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!