Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago