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
The code segment below displays a table of numbers. Select an expression to complete the code segment, so that the resulting algorithm has O(n2) running time. for (int k = 1; k <= n; k++)
{
For _______________________
{
System.out.print(j + " ");
}
System.out.println();
}
(Multiple Choice)
4.8/5
(43)
Suppose an array has n elements. We visit element #1 one time, element #2 two times, element #3 three times, and so forth. How many total visits will there be?
(Multiple Choice)
4.7/5
(50)
An algorithm that tests whether the first array element is equal to any of the other array elements would be an ____ algorithm.
(Multiple Choice)
4.8/5
(30)
Which selection sort iteration guarantees the array is sorted for a 10-element array?
(Multiple Choice)
4.8/5
(43)
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.7/5
(32)
Which of the sorts in the textbook can be characterized by the fact that the best case will have a running time of θ(n) if the data is already sorted?
I quicksort
II selection sort
III insertion sort
(Multiple Choice)
4.8/5
(40)
If the array is already sorted, what is the performance of insertion sort?
(Multiple Choice)
4.9/5
(41)
Consider the sort method for selection sort shown below: public static void sort (int[]A) An exception would occur
(Multiple Choice)
4.9/5
(40)
Consider the sort method shown below for selection sort: public static void sort (int[]A) An exception would occur.
(Multiple Choice)
4.7/5
(34)
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.8/5
(32)
In big-Oh notation, suppose an algorithm requires an order of n3 element visits. How does doubling the number of elements affect the number of visits?
(Multiple Choice)
4.7/5
(48)
Consider the swap method shown below from the SelectionSorter class. If we modified it as shown in the swap2 method shown below, what would be the effect on the sort method? private static void swap(int[] a, int i, int j)
{
Int temp = a[i];
A[i] = a[j];
A[j] = temp;
}
Private static void swap2(int[] a, int i, int j)
{
A[i] = a[j];
A[j] = a[i];
}
(Multiple Choice)
4.8/5
(45)
Suppose objects a and b are from a user-defined class that implements the Comparable interface. Which condition tests the compareTo method's return value to determine that a will precede b when the sort method is called?
(Multiple Choice)
4.9/5
(31)
In the textbook, we determined that the merge method requires a total of 5n visits. We found that the number of visits required to sort an array of n elements is T(n) = T(n / 2) + T(n / 2) + 5n. What does T(n / 2) describe?
(Multiple Choice)
4.7/5
(42)
Which sort algorithm starts by partitioning the array and selecting a pivot element?
(Multiple Choice)
4.8/5
(39)
Showing 61 - 80 of 109
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)