Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Write two recursive versions of the function minInArray . The function will be given a sequence of elements and should return the minimum value in

Write two recursive versions of the function

minInArray

. The function will be given a

sequence of elements and should

return the minimum value in that sequence.

The two versions

differ from one another in the technique we use to pass the sequence to the function.

In version 1 - The portotype function should be:

int minInArray1(int arr[],int arrSize)

Here, the function is given arr, an array of integers, and its logical size, arrSize

The function should find the minimum value out of all the elements in positions:

0, 1, 2, ..., arrSize-1.

In version 2 The prototype of the function should be:

int minInArray2(int arr[], int low, int high)

Here, the function is given arr, an array of integers and two addittional indices: low and high

(low image text in transcribed high), which indicates the range of incides that need to be considered.

The function should find the minimum value out of all the elements in positions:

low, low+1, ..., high

Use the following main to check your program:

int main() { int arr[10] = {9, -2, 14, 12, 3, 6, 2, 1, -9, 15}; int res1, res2, res3, res4;

res1 = minInArray1(arr, 10); res2 = minInArray2(arr, 0, 9); cout

res3 = minInArray2(arr, 2, 5); res4 = minInArray1(arr+2, 4); //arr+2 is equivalent to &(arr[2]) cout

return 0;

}

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

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students explore these related Databases questions

Question

1.what is the significance of Taxonomy ?

Answered: 3 weeks ago

Question

Name is needed for identifying organisms ?

Answered: 3 weeks ago