Question
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:
- Class name is ArrayUtil
- Has an integer array field named intArray
- A default constructor
- 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.
- An accessor for the field.
- A mutator for the field.
- A method called minValue that does not accept any arguments and finds the minimum (smallest) value in the integer array and returns that value.
- A method called maxValue that does not accept any arguments and finds the maximum (largest) value in the integer array and returns that value.
- 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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started