Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

in java please! thank you. 1) Write the function successes that accepts an Array

ID: 3816337 • Letter: I

Question

in java please! thank you.

1) Write the function successes that accepts an ArrayList of all the integers and returns and ArrayList of booleans that indicates whether the individual integers of the argument list are strictly greater than 10. Ordering must be preserved.

2) in regards to arraylists how does insertion work in the underlying array?

3) what needs to be true about our data in order to use binary search ?

4) write a method (named singleton) that accepts an argument of a generic type and returns a List of that generic type, adding the argument as the only value in the list

what is a type parameters list?

Explanation / Answer

1) function that accepts arraylist of integers and returns boolean arraylist

public static ArrayList<Boolean> successes(ArrayList<Integer> list) /* function successes declartion with input arraylist of integers and returns arraylist of boolean values */

{
ArrayList<Boolean> list1 = new ArrayList<Boolean>(); /* a new arraylist of boolean values is created as list1 inorder to store our result */
for(Integer temp : list){ // here we are reading our list elements using for loop
    if(temp > 10) // here we are checking whether the number is greaterthan 10 or not
    list1.add(Boolean.TRUE); /* here if the above condition is true we add boolean true value to above created boolean list */
    else
    list1.add(Boolean.FALSE); /* here if the condition fails we add boolean false to above created boolean list */

}
return list1; // here we are returning obtaind boolean arraylist to calling function
}