Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) Public int search(int target): if the target is found in the array, return the frequency of its showing up. If the target is

image

1) Public int search(int target): if the target is found in the array, return the frequency of its showing up. If the target is not found in the array, return -1. If the array is empty, return -1; 2) Public int maximum(): Return the maximum number in the array if the array is nonempty, otherwise return Integer.MIN_VALUE; 3) Public int minimum(): Return the minimum number in the array if the array is nonempty, otherwise return Integer.MAX_VALUE; 4) Public int getElement(int index): Return the value at index. If index does not exist, return the Integer.MIN_VALUE and print out IndexOutOfBoundsException". 5) Public void setElement(int index, int value): Set the value at index. If index does not exist, print out "IndexOutOfBoundsException". 6) Public void addElement(int value): Set the value in the cell at the end of the elements (Note the end of your elements is not the end of the array(length-1)). If array is full, you need to call the a private method to resize your array(double the size and copy all elements in original array to the new array and return the new array). 7) Public void sort(): Sort the elements in the array in ascending order. Note that after resizing, there might be lots of Os but you cannot sort those Os, since they are not added by user. 8) Public void printArray(): Display all of elements(given by user only) in the array. 9) Public void delete(int value): Delete all the elements in the array with given value and reorganize the array without any empty spaces btw any two elements. For example, given an array as {1, 0, 1, 2}, after we invoke delete(1), your array should be {0, 2}.

Step by Step Solution

3.47 Rating (154 Votes )

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

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

College Physics

Authors: Jerry D. Wilson, Anthony J. Buffa, Bo Lou

7th edition

9780321571113, 321601831, 978-0321601834

More Books

Students also viewed these Programming questions

Question

=+b) Obtain a forecast for the week of May 28, 2007.

Answered: 1 week ago

Question

Evaluate the integral, if it exists. Jo y(y + 1) dy

Answered: 1 week ago