QUESTION 11 Which of the following classes implement the Comparable interface? I
ID: 3800269 • Letter: Q
Question
QUESTION 11
Which of the following classes implement the Comparable interface?
I Date
II Collections
III String
I
I and II
I and III
II and III
QUESTION 12
Can you search the following array using binary search?
Yes. Binary search can be applied to any array.
No. Binary search can be applied to a sorted array only.
Yes, but the algorithm runs slower because the array is in descending order.
No, negative numbers are not allowed because they indicate that a value is not present.
QUESTION 13
Consider the sort method for selection sort shown below:
Suppose we modify the loop control to read int i = 1; i < a.length – 1; i++. What would be the result?
An exception would occur
The sort would not consider the last array element.
The sort would not consider the first array element.
The sort would still work correctly.
QUESTION 14
Consider the sort method shown below for selection sort:
Suppose we modify the loop condition to read i < a.length. What would be the result?
An exception would occur.
The sort would work, but run one more iteration.
The sort would work but with one less iteration.
The sort would work exactly the same as before the code modification.
QUESTION 15
Suppose you have a phone number and need to find the address that it corresponds to. If there are 2,000,000 entries, how many do you expect to search in a printed phone directory before finding the address you are looking for?
Approximately 50,000 records.
Approximately 75,000 records.
Approximately 1,000,000 records.
Approximately 1,200,000 records.
QUESTION 16
What type of algorithm places elements in order?
sorting
searching
insertion
deletion
QUESTION 17
Assume we are using quicksort to sort an array in ascending order. What can we conclude about the indexes of two pivot elements placed in consecutive recursive calls?
They are randomly located.
They are in different halves of the array.
They are both in the same half of the array.
They are adjacent.
QUESTION 18
The following code is an example of a ___ search.
sorted
binary
linear
random
QUESTION 19
The performance of an algorithm is most closely related to what?
The total number of element visits
The total number of elements
The type of elements
The number of lines of code in the method
QUESTION 20
The ____ class contains a sort method that can sort array lists.
Sorting
Arrays
Collections
Linear
I
I and II
I and III
II and III
Explanation / Answer
Q11)11 and 111 // because in Java Comparable interface is used to order the objects of user-defined class.
Q12)NO binary search can be applied for sorted array only
Q13)The sort would not consider the first array element
and the sort would not consider the last element // because as i=1 it neglects the i=0 first element and //i<a.length -1
Q14)The sort would work, but run one more iteration.
Q16)sorting
Q17)they are randomly located based on the input
Q18)linear
Q20)collections
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.