Which of the following statements are true?
A) Collections.shuffle(list, Random) randomly reorders the elements in the list with a specified Random object.
B) If list1 and list2 are identical, the two lists are still identical after invoking Collections.sort(list1, new Random(3)) and Collections.sort(list2, new Random (3)) with the same Random object
C) Collections.shuffle(list) randomly reorders the elements in the list
D) If list1 and list2 are identical, the two lists may be different after invoking Collections.sort(list1) and Collections.sort(list2)
Solution
Answer
A-True
B-True
C-True
D-True
Explanation
A & C) Collections.shuffle(list, Random) randomly reorders the elements in the list with a specified Random object.
General Form
public static void shuffle(List<?> list, Random random)
Example
List<String> list = Arrays.asList("G", "H", "I", "J");
Collections.shuffle(list);
Hence Answer is True
B & D)If list1 and list2 are identical, the two lists are still identical after invoking Collections.sort(list1, new Random(3)) and Collections.sort(list2, new Random (3)) with the same Random object
If list1 and list2 are identical, the two lists may be different after invoking Collections.sort(list1) and Collections.sort(list2)
Hence Answer is True
--
all the best
Which of the following statements are true? A) Collections.shuffle(list, Random) randomly reorders the elements in the...
Deletion of List Elements The del statement removes an element or slice from a list by position. The list method list.remove(item) removes an element from a list by it value (deletes the first occurance of item) For example: a = ['one', 'two', 'three'] del a[1] for s in a: print(s) b = ['a', 'b', 'c', 'd', 'e', 'f', 'a', 'b'] del b[1:5] print(b) b.remove('a') print(b) # Output: ''' one three ['a', 'f', 'a', 'b'] ['f', 'a', 'b'] ''' Your textbook...
Need help with program. I'm stuck Objectives: In this assignment, we will practice manipulating lists of data and arranging items in an ascending/descending order. you will also explore storing lists/arrays using different sorting algorithms including, the selection sort, bubble sort, and insertion sort algorithm. Comparison between the three algorithms are made based on the number of comparisons and item assignments (basic operations) each algorithms executes. Background: Ordering the elements of a list is a problem that occurs in many computer...
c++ please no global varaible write a value returning function input data to dynamically allocate a short array of size elements and store the input data entered from the disk file into array.Return the base address of the array allocated.Read the data from the text file Hello.txt and store the data in reverse order in the array.the size of the data set will be in the file size 10 and the data was 1 2 3 4 5 6 7...
D Question 12 1.5 pts Check the true statements about NumPy arrays: O A single instantiated NumPy array can store multiple types (e.g., ints and strings) in its individual element positions. A NumPy array object can be instantiated using multiple types (e.g., ints and strings) in the list passed to its constructor O Memory freeing will require a double-nested loop. The number of bits used to store a particular NumPy array object is fixed. O The numpy.append(my.array, new_list) operation mutates...
Add the following methods to the ArrayList class that we wrote during lecture. You may call the existing methods in ArrayList if you want, but do not use anything from the built-in java.util.ArrayList class. 1. (3 pts) Write a new method named addAll(ArrayList anotherList) that adds all the elements in anotherList to the back of the calling list. Be sure to reallocate the data array if necessary. anotherList should not be modified. 2. (4 pts) Write a new method named...
Which of the following statements regarding natural selection is not true? It is a random process. A favorable trait in one environment is not always a favorable trait in a different environment. It is a mechanism by which evolution may occur. It occurs even if the frequency of the specific trait doesn't change over many generations.
Which of the following statements is TRUE about X inactivation? A. Inactivation of a particular X chromosome depends on its genetic content. Inactivated X chromosomes are in some way "marked" such that all clonally related cells (daughter cells) have the same X chromosome inactivated. B. Inactivation of an X chromosome occurs at random early in embryonic development. Inactivated X chromosomes are in some way "marked" such that all clonally related cells (daughter cells) have the same X chromosome inactivated. C....
The following is for java programming. the classes money date and array list are so I are are pre made to help with the coding so you can resuse them where applicable Question 3. (10 marks) Here are three incomplete Java classes that model students, staff, and faculty members at a university class Student [ private String lastName; private String firstName; private Address address; private String degreeProgram; private IDNumber studentNumber; // Constructors and methods omitted. class Staff private String lastName;...
FLUID o True False 1 pts Question 3 Which of the following statements about MEIOSIS are CORRECT? Only haploid cells are produced Sister chromatids are separated during anaphase I and homologous chromosomes are separated during anaphase II After crossing over (recombination) the sister chromatids are still identical There are two rounds of cell division following only one round of DNA synthesis non-disjunction can occur during either anaphase I or Il 1 pts Question 4