Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Developing a Utility Array The challenge in the project is developing algorithms that accomplishes basic operations over an array of integer numbers. The three operations

Developing a Utility Array

The challenge in the project is developing algorithms that accomplishes basic operations over an array of integer numbers.

The three operations are:

  • Find the minimum (smallest) value that appears in the array
  • Find the maximum (largest) value that appears in the array
  • Determine the number of unique values that appear in the array

Develop an algorithm for each of those tasks. The algorithms should work for any size of array. If the array is empty (i.e., doesn't include any elements/values) the algorithm should output a zero.

Keep in mind that like any computational problem there are several approaches to achieve a solution. For this programming checkpoint you will need to utilize loops and conditional statements.

In VSCode create a class with the following requirements:

  1. Class name is ArrayUtil
  2. Has an integer array field named intArray
  3. A default constructor
  4. A constructor that accepts one argument for the array field and assigns that argument to the appropriate field. You may assume that only valid values (see 6a below) will be used to test the constructor.
  5. An accessor for the field.
  6. A mutator for the field.
  7. A method called minValue that does not accept any arguments and finds the minimum (smallest) value in the integer array and returns that value.
  8. A method called maxValue that does not accept any arguments and finds the maximum (largest) value in the integer array and returns that value.
  9. A method called countUniqueIntegers that does not accept any arguments and determines the number of unique values that appear in the array and returns that value. (i.e., count of the number of unique integer values in an array).

  • Add a method that will return an array that will only contain the unique values of the original array (i.e., remove duplicates)
  • Add a method that given two element positions (indices) in the array swaps the two elements with each other.
  • Add a method that determines whether the array is sorted or not. This method should allow for specifying whether the sorting to be determined is in descending or ascending order.

Step by Step Solution

3.53 Rating (163 Votes )

There are 3 Steps involved in it

Step: 1

Heres an implementation o... 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

Step: 3

blur-text-image

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

Managerial Economics

Authors: Mark Hirschey

12th edition

9780324584844, 324588860, 324584849, 978-0324588866

More Books

Students also viewed these Accounting questions