Question: I need these programs an Java for a dome program void set ( int idx, int val ) { / / Set the element located

I need these programs an Java for a dome program
void set(int idx, int val){
// Set the element located at idx with the given value.
// eg) Suppose elements =[10,5,20,14,30], set(1,99) changes it to [10,99,20,14,30]
// Do nothing if idx is invalid.
}
void add(int idx, int val){
// Add the given element (val) at the given location (idx)
// Assume that the given index is valid
// Send the existing element to the end.
// eg) Suppose elements =[10,5,20,14]. add(1,99) will change it to [10,99,20,14,5]
// Make sure there are enough space for the new element.
}
void add(int[] valArray){
// Add all the elements of the given array 'valArray' at the end of the array 'elements'.
// Make sure there are enough empty space for the new array.
// Calling enlarge() once may not be enough. ensureCapacity will be more useful.
}
Integer max(){
// Return the maxinum value among the existing elements.
// Return null if empty
return null; // This is here to avoid syntax error. Change if needed
}
int[] copy(int start, int end){
// Return a new copy of the array between index 'start' and 'end' inclusive.
// eg) Suppose elements =[10,5,20,14,30]. get(1,3) returns a new array [5,20,14]
// Assume that both index start and end are valid.
// If start > end, then return the elements in reverse order.
// eg) Suppose elements =[10,5,20,14,30]. get(3,1) returns a new array [14,20,5]
return null; // This is here to avoid syntax error. Change if needed
}
I need these programs an Java for a dome program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!