Exam 14: Sorting and Searching
Exam 1: Introduction96 Questions
Exam 2: Fundamental Data Types103 Questions
Exam 3: Decisionseasy99 Questions
Exam 4: Loops100 Questions
Exam 5: Methods94 Questions
Exam 6: Arrays and Arraylists100 Questions
Exam 7: Inputoutput and Exception Handling100 Questions
Exam 8: Objects and Classes101 Questions
Exam 9: Inheritance and Interfaces99 Questions
Exam 10: Graphical User Interfaces54 Questions
Exam 11: Advanced User Interfaces91 Questions
Exam 12: Object-Oriented Design100 Questions
Exam 13: Recursion100 Questions
Exam 14: Sorting and Searching99 Questions
Exam 15: The Java Collections Framework100 Questions
Exam 16: Basic Data Structures94 Questions
Exam 17: Tree Structures100 Questions
Exam 18: Generic Classes78 Questions
Exam 19: Streams and Binary Inputoutput82 Questions
Exam 20: Multithreading82 Questions
Exam 21: Internet Networking74 Questions
Exam 22: Relational Databases75 Questions
Exam 23: XML74 Questions
Exam 24: Web Applications74 Questions
Select questions type
How many times can an array with 4,096 elements be cut into two equal pieces?
(Multiple Choice)
4.7/5
(37)
Consider the sort method shown below for selection sort:
public static void sort(int[] a) {
For (int i = 0; i < a.length - 1; i++)
{
int minPos = minimumPosition(i);
swap(minPos, i);
}
}
Suppose we modify the loop condition to read i < a.length. What would be the result?
(Multiple Choice)
4.8/5
(38)
Suppose objects a and b are from a user-defined class that implements the Comparable interface. What must be true about the return value of a.compareTo(b) for the compareTo method that this class implements?
(Multiple Choice)
4.9/5
(28)
Which of the following arrays can be used in a call to the Arrays.sort method?
I Any array with primitive numeric data, such as int, double, …
II Arrays of String or numeric wrapper classes like, Integer, Double, …
III Any class that implements the Comparable interface
(Multiple Choice)
4.9/5
(41)
Which sort algorithm starts with an initial sequence of size 1, which is assumed to be sorted, and increases the size of the sorted sequence in the array in each iteration?
(Multiple Choice)
4.8/5
(35)
In each iteration, selection sort places which element in the correct location?
(Multiple Choice)
4.8/5
(31)
Suppose we are using binary search on an array with approximately 1,000,000 elements. How many visits should we expect to make in the worst case?
(Multiple Choice)
4.8/5
(41)
Which notation, big-Oh, theta, or omega describes the growth rate of a function?
I big-Oh
II theta
III omega
(Multiple Choice)
4.7/5
(43)
After one iteration of selection sort working on an array of 10 elements, what must hold true?
(Multiple Choice)
4.9/5
(35)
Suppose a developer gets class XYZ files and documentation from a subcontractor. This class does not implement the Comparable interface. What must be true in order for the developer to sort an array of XYZ objects without modifying the xyz class?
(Multiple Choice)
4.8/5
(31)
If you increase the size of a dataset fivefold, how much longer does it take to sort it with the selection sort algorithm?
(Multiple Choice)
4.9/5
(42)
Suppose an algorithm requires a total of 3n3 + 2n2 - 3n + 4 visits. In big-Oh notation, the total number of visits is of what order?
(Multiple Choice)
4.9/5
(38)
A version of which sort algorithm is used in the sort method in the Java Arrays class?
(Multiple Choice)
4.7/5
(36)
In the textbook, we found that the number of element visits for merge sort totaled
N + 5n log2 n. Which of the following is the appropriate big-Oh notation for merge sort?
(Multiple Choice)
4.9/5
(35)
If the Arrays static method binarySearch is called on an array of 10 elements and returns a value of 10, what can be concluded?
I the element is not found
II that value cannot be returned from method binarySearch
III if added, the element would be the largest element in the array
(Multiple Choice)
4.9/5
(38)
The sort method of the Arrays class sorts arrays containing objects of classes that implement the ____ interface.
(Multiple Choice)
4.9/5
(43)
A portion of your program implements a loop in which each step contains a fixed number of actions. What can you conclude about the running time of this section of code?
(Multiple Choice)
4.9/5
(35)
The method findLargest examines the elements of an array arr which contains non-negative values
Public static int findLargest(int[] arr)
{
Int curLargest = -1;
For (int i = 0; i < arr.length; i++)
{
If (arr[i] >= curLargest)
{
CurLargest = arr[i];
}
}
Return curLargest;
}
What can you conclude about the running time of this section of code?
(Multiple Choice)
4.8/5
(36)
If a call to the Arrays static method binarySearch returns a value of 7, what can be concluded?
I the element is not in the array
II the element is at index 7
III the element occurs 7 times in the array
(Multiple Choice)
4.9/5
(42)
Showing 81 - 99 of 99
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)