Question: // A practice program for recursion: CS3358(Fall 2018) Assignment 6 Part 1A #include #include #include using namespace std; // prototype for LowIndexMinNeg (to be filled
// A practice program for recursion: CS3358(Fall 2018) Assignment 6 Part 1A #include
// prototype for LowIndexMinNeg (to be filled in - part of exercise) int LowIndexMinNeg(int a[], int size); void SeedRand(); int BoundedRandomInt(int lowerBound, int upperBound); void ShowArray(const int a[], int size); void DebugShowCase(int whichCase, int totalCasesToDo, const int caseValues[], int caseSize);
int main() { int testCasesToDo = 900000, testCasesDone = 0, loSize = 0, hiSize = 20, loValue = -9, hiValue = 9; int numInts, used, intCount, limnO2B, limn, newInt; int *intArr = 0;
// SeedRand(); // disabled for reproducible result
do { ++testCasesDone; limnO2B = -999; numInts = BoundedRandomInt(loSize, hiSize); if (numInts > 0) intArr = new int [numInts]; used = 0; for (intCount = 0; intCount
limn = LowIndexMinNeg(intArr, used);
if (limn != limnO2B) { cout
if (testCasesDone "
return EXIT_SUCCESS; }
///////////////////////////////////////////////////////////////////// // Function to seed the random number generator // PRE: none // POST: The random number generator has been seeded. ///////////////////////////////////////////////////////////////////// void SeedRand() { srand( (unsigned) time(NULL) ); }
///////////////////////////////////////////////////////////////////// // Function to generate a random integer between // lowerBound and upperBound (inclusive) // PRE: lowerBound is a positive integer. // upperBound is a positive integer. // upperBound is larger than lowerBound // The random number generator has been seeded. // POST: A random integer between lowerBound and upperBound // has been returned. ///////////////////////////////////////////////////////////////////// int BoundedRandomInt(int lowerBound, int upperBound) { return ( rand() % (upperBound - lowerBound + 1) ) + lowerBound; }
void ShowArray(const int a[], int size) { for (int i = 0; i
void DebugShowCase(int whichCase, int totalCasesToDo, const int caseValues[], int caseSize) { cout
// Definition of LowIndexMinNeg.
|
this is Data Structure.
|
Part 1A (25 points) (posted 10/17/2018, DUE 10/24/2018) This part of the assignment aims at providing you with a programming exercise involving recursion and array (Supplied Files) You are to write a recursive C++ function that searches for the "smallest negative value" in a given (unsorted) array of integers a of sizc n. The function should return the index of the "smallest ncgative value" found in a or -99 if no "smallest negative value" can be found (such as when no or all values in the array are non-negative). If two ormore clements meet the search condition, then the index of the leftmost among them (i.e. the one with the lowest index) is to be returned IMPORTANT Specific Requirements The function should: Have only two parameters (array name and size) Not use any globat variables or static local variables; Not use any looping constructs (for, while, do-while,. Be directly (not indirectly) recursive. For uniformity, namet he function LowindexMinNeg Examples(scc a6plAtest.out of Supplicd Filcs for more) ven array (a) (zero-sized array) t0) Value returned t0 1 [0-11 [i -21 [1 2 31
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts



![filled in - part of exercise) int LowIndexMinNeg(int a[], int size); void](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3a74284118_09866f3a7420b6b2.jpg)