Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solve it By JAVA please. DO NOT USE IMPORT. THANKS Method 2: public static int smallest(int[] values) This method will return the smallest value found

Solve it By JAVA please.

DO NOT USE IMPORT.

THANKS

Method 2: public static int smallest(int[] values)

This method will return the smallest value found in the array. For example, for the array {4, 2, 3, 1, 5, 1}, the value 1 will be returned. If the array is empty, then the built-in constant Integer.MAX_VALUE may be returned.

Method 3: public static int smallestGreaterThanN(int n, int[] values)

This method will return the smallest value found in the array which is larger than the input n. For example, for the input n = 2 and the array {4, 2, 3, 1, 5, 1}, the value 3 will be returned. If no such value exists, then the method will return the value n.

Method 4: public static int numDistinct(int[] values)

Return the total number of distinct values contained in the input array. For example, the array {2, 2, 5, 1, 7, 4, 7} has 5 distinct values (the numbers 1, 2, 4, 5, and 7). Each of those five values appear at least once (the numbers 2 and 7 appear twice each, but they are only counted once).

Hint: calls to smallest() and smallestGreaterThanN() may help you solve this.

Method 5: public static int numOccurrences(int v, int[] values)

Determines the number of times element v occurs within the array of values. For example, in the array {1, 2, 5, 5, 3, 2}, the value v = 2 occurs twice.

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

Deductive And Object Oriented Databases Second International Conference Dood 91 Munich Germany December 18 1991 Proceedings Lncs 566

Authors: Claude Delobel ,Michael Kifer ,Yoshifumi Masunaga

1st Edition

3540550151, 978-3540550150

More Books

Students also viewed these Databases questions