1) Public int search(int target): if the target is found in the array, return the frequency...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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}. 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}.
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
answer the question clearly You are building a flight-control system for which a convincing safety case must be made. Would you assign the tasks of safety requirements engineering, test case...
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
The degree of operating leverage for Dousmann Corp. and PCB Co. are 1.4 and 5.6, respectively. Both have net incomes of $50,000. Determine their respective contribution margin s.
-
Listed below are job stress scores and median annual salaries (thousands of dollars) for various jobs, including firefighters, airline pilots, police officers, and university professors (based on...
-
The Salida Salt Company is considering making a bid to supply the highway department with rock salt to drop on roads in the county during the winter. The contract will guarantee a minimum of 25,000...
-
The time constant for the discharge of this capacitor is. A. 5 s B. 4 s C. 2 s D. 1 s ww 202 20 ww HH 1 F
-
Helix Company produces several products in its factory, including a karate robe. The company uses a standard cost system to assist in the control of costs. According to the standards that have been...
-
Your company has $15,000 to invest. You find two investments. Investment 1 requires an investment of $10,000 and has a profitability index of 1.5. Investment 2 requires an investment of 14,000 and...
-
Refer to the drawing of four identical tank differential pressure (D/P) level detectors (see figure below). The tanks are identical and are currently at 2 psig overpressure, the same constant water...
-
An electric charge of 5 mu C is found in air 5 0 cm from another charge; If the repulsive force is 0 . 7 2 N , , what value will q 2 have?
-
Imagine that you are environmental studies major who just graduated with your degree from University. You are applying for Environmental Scientist: Entry-Level position that you are interested in and...
-
Bill Owens made thousands of small entries spread out over 1,500 ledgers deemed to small to be reviewed by the auditors. What part of the fraud triangle does this action related to?
-
write a brief method of investing involves holding securities of companies in other countries.
-
If you borrow $5,000 to buy a car at 1% per month, to be repaid over the next four years, determine the correct excel statement to solve your monthly payment. O a(1%, 48, 5000) Opmt(1%, 4, 5000) O...
-
What is the lattice energy of Li3N?
-
Evaluate the integral, if it exists. Jo y(y + 1) dy
-
A man has a mass of 75 kg on the Earths surface. How far above the surface of the Earth would he have to go to lose of his body weight?
-
A nearsighted woman has a far point located 2.00 m from one eye. (a) If a corrective lens is worn 2.00 cm from the eye, what would be the necessary power of the lens for her to see distant objects?...
-
Water towers (storage tanks) are generally bulb shaped, as shown in Fig. 9.29. Wouldnt it be better to have a cylindrical storage tank of the same height? Explain. PLAINS
-
The IT implementation project is bogging down and falling behind schedule. The department heads are complaining that the project cannot help them if it is not implemented in a reasonable time frame....
-
This isnt what I need! objected the admissions officer at Northwest Regional Hospital. Judy sighed, But this is the software you asked us to create for you. I dont care what I said at the time, this...
-
Assume the network diagram shown in Figure 11.19. Megan is responsible for activities A and C. Use the critical chain methodology to resource-level the network. What are two options for redrawing the...
Study smarter with the SolutionInn App