Question: Description Write two Java methods which return the minimum value in an integer array. You should write: An iterative method which returns the minimum value

Description

Write two Java methods which return the minimum value in an integer array. You should write:

An iterative method which returns the minimum value in an integer array. In this method, you must use either a for or a while loop. You should call this method minArrayIter and it should have a definition as follows: public static int minArrayIter(int[] a) where a is the input array.

A recursive method which returns the minimum value in an integer array. You should call this method minArrayRec. The definition of the method should be declared as follows: public static int minArrayRec(int[] a, int start) where a is the input array.

You may assume that there will always be at least one element in the array.

Input

 n, m, where n is the length of the array, followed by m numbers 

Sample Input

 6 19 190 1990 9 90 1 

Output

Each method will return the value which is the minimum value in the integer array to be printed on the same line separated by a space

Sample Output

 1 1

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!