Exam 14: Sorting and Searching
Exam 1: Introduction98 Questions
Exam 2: Using Objects76 Questions
Exam 3: Implementing Classes103 Questions
Exam 4: Fundamental Data Types125 Questions
Exam 5: Decisions120 Questions
Exam 6: Loops128 Questions
Exam 7: Arrays and Array Lists118 Questions
Exam 8: Designing Classes95 Questions
Exam 9: Inheritance101 Questions
Exam 10: Interfaces85 Questions
Exam 11: Inputoutput and Exception Handling109 Questions
Exam 12: Object-Oriented Design104 Questions
Exam 13: Recursion110 Questions
Exam 14: Sorting and Searching109 Questions
Exam 15: The Java Collections Framework110 Questions
Exam 16: Basic Data Structures104 Questions
Exam 17: Tree Structures110 Questions
Exam 18: Generic Classes75 Questions
Exam 19: Graphical User Interfaces76 Questions
Exam 20: Streams and Binary Inputoutput82 Questions
Exam 21: Multithreading82 Questions
Exam 22: Internet Networking74 Questions
Exam 23: Relational Databases75 Questions
Exam 24: XML74 Questions
Exam 25: Web Applications75 Questions
Select questions type
An algorithm that cuts the work in half in each step is an ____ algorithm.
(Multiple Choice)
4.7/5
(38)
The binarySearch method of the Collections class returns a value in the form of -k - 1 when the target item you are searching for was not found in the array. What does k represent?
(Multiple Choice)
4.8/5
(40)
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.7/5
(30)
Which of the sorts in the textbook are based on the strategy of divide and conquer?
I quicksort
II mergesort
III insertion sort
(Multiple Choice)
5.0/5
(39)
Selection sort has O(n2) complexity. If a computer can sort 1,000 elements in 4 seconds, approximately how many seconds will it take the computer to sort 1,000 times that many, or 1,000,000 elements?
(Multiple Choice)
4.9/5
(36)
In each iteration, selection sort places which element in the correct location?
(Multiple Choice)
4.7/5
(35)
Suppose the call obj1.compareTo(obj2) returns 0. What can definitely be concluded from the return value?
I obj1 and obj2 are the same object
II obj1 and obj2 objects cannot be compared
III the properties of obj1 and obj2 that are being compared have identical values
(Multiple Choice)
4.9/5
(36)
Suppose you wish to sort an array list of objects, but the object class does not implement the Comparable interface. Because you are not allowed to modify this class, you decide to provide a comparator object that implements the Comparator interface. Which method must you implement from this interface to achieve your objective?
(Multiple Choice)
4.9/5
(42)
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)
5.0/5
(38)
How many times can an array with 729 elements be cut into three equal pieces?
(Multiple Choice)
4.9/5
(39)
Consider the sort method shown below for selection sort: public static void sort(int[]A) An exception would occur.
(Multiple Choice)
4.9/5
(34)
If you implement a recursive linear search, its performance will be ____.
(Multiple Choice)
4.8/5
(44)
Given the following code snippet for searching an array:
Int[] arr = {3, 8, 12, 14, 17};
Int newVal = 15;
Int pos = Arrays.binarySearch(arr, newVal);
What value will pos have when this code is executed?
(Multiple Choice)
4.9/5
(46)
The code segment below prints some of the elements in an array with size n. Select an expression to complete the code segment so that the resulting algorithm has O(log n) running time. for __________________________
{
System.out.println(array[j]);
}
(Multiple Choice)
4.9/5
(39)
How many comparisons does selection sort make when sorting an array of length n?
(Multiple Choice)
4.7/5
(39)
If an element is present in an array of length n, how many element visits, on average, are necessary to find it using a linear search?
(Multiple Choice)
4.8/5
(33)
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.8/5
(34)
The code segment below is designed to add the elements in an array of integers. Select the expression needed to complete the code segment so that it calculates the running time elapsed. long start = System.currentTimeMillis();
Int sum = 0;
For (int k = 0; k < values.length; k++)
{
Sum = sum + values[k];
}
Long runningTime = ____________________________;
(Multiple Choice)
4.8/5
(33)
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
(39)
Showing 21 - 40 of 109
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)