subject
Computers and Technology, 25.11.2021 06:40 ian1588

***IN JAVA Write array methods that carry out the following tasks for an ArrayList of integers by completing the Exercise class below.
Call each method from a main method in a Main class.
public class Exercise3 {
private ArrayList values;
public ArrayMethods(int[] initialValues) {
values = initialValues;
}
public void swapFirstAndLast() {
...
}
public void shiftRight() {
...
}
...
}
a. Swap the first and last elements in the array.
b. Shift all elements to the right by one and move the last element into the first position. For example, 1 4 9 16 25 would be transformed into 25 1 4 9 16.
c. Replace all even elements with 0.
d. Replace each element except the first and last by the larger of its two neighbors.
e. Remove the middle element if the array length is odd, or the middle two elements if the length is even.
f. Move all even elements to the front, otherwise preserving the order of the elements.
g. Return the second-largest element in the array.
h. Return true if the array is currently sorted in increasing order.
i. Return true if the array contains two adjacent duplicate elements.
j. Return true if the array contains duplicate elements (which need not be adjacent).

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 21:30
Nathan wants to create multiple worksheet containing common formatting styles for his team members. which file extension him to save these worksheets? nathan to create multiple worksheets with common styles. he needs to save them with the extension.
Answers: 1
question
Computers and Technology, 22.06.2019 23:50
You need to design a circuit that implements the functions in the following table: s0 s1 function0 0 a + 10 1 a – b1 0 a + b1 1 a – 1s0 and s1 are 1-bit control inputs to select the function of the circuit. inputs a and b are 4-bitnumbers in 2s complement form. the output is also a 4-bit number in 2s complement form.you are allowed to use only one ttl 7483 4-bit adder to implement all the functions. but anynumber of other components (except the adder) can be used.hint: design a combinational logic circuit to modify the input b and the “carry input” of theadder depending on the control inputs s0 and s1.important: lab grade will depend on the working of the circuit & will be checked of by your labinstructor.1. is the output valid for the following input combinations: a. s0 = 0, s1 = 0, a = 7, b = 3? b. s0 = 0, s1 = 1, a = 7, b = 3? c. s0 = 1, s1 = 0, a = -4, b = -5? d. s0 = 1, s1 = 1, a = -8, b = 6? 2. what is the range of inputs (for both a and b) that will produce the valid output for all the functions?
Answers: 3
question
Computers and Technology, 24.06.2019 07:00
Why do we mark tlc plates with pencil and not with pen
Answers: 2
question
Computers and Technology, 24.06.2019 10:00
When writing a business letter, how many times can you use the same merge field in a document? once once, unless using the address block feature unlimited it will depend on the type of document you choose
Answers: 1
You know the right answer?
***IN JAVA Write array methods that carry out the following tasks for an ArrayList of integers by...
Questions
question
Mathematics, 17.01.2020 09:31
Questions on the website: 13722363