Services
Discover
Ask a Question
Log in
Sign up
Filters
Done
Question type:
Essay
Multiple Choice
Short Answer
True False
Matching
Topic
Computing
Study Set
Big Java Binder Early Objects
Exam 14: Sorting and Searching
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 61
Multiple Choice
The code segment below displays a table of numbers. Select an expression to complete the code segment, so that the resulting algorithm has O(n
2
) running time. for (int k = 1; k <= n; k++) { For _______________________ { System.out.print(j + " ") ; } System.out.println() ; }
Question 62
Multiple Choice
In the worst case, quicksort is a(n) ____ algorithm.
Question 63
Multiple Choice
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?
Question 64
Multiple Choice
An algorithm that tests whether the first array element is equal to any of the other array elements would be an ____ algorithm.
Question 65
Multiple Choice
Which selection sort iteration guarantees the array is sorted for a 10-element array?
Question 66
Multiple Choice
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?
Question 67
Multiple Choice
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
Question 68
Multiple Choice
If the array is already sorted, what is the performance of insertion sort?
Question 69
Multiple Choice
What is the smallest value of n for which n
2
> 3n + 4?
Question 70
Multiple Choice
Consider the sort method for selection sort shown below: public static void sort (int[]A) An exception would occur
Question 71
Multiple Choice
What is the worst-case performance of insertion sort?
Question 72
Multiple Choice
Consider the sort method shown below for selection sort: public static void sort (int[]A) An exception would occur.
Question 73
Multiple Choice
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
Question 74
Multiple Choice
What type of algorithm places elements in order?
Question 75
Multiple Choice
In big-Oh notation, suppose an algorithm requires an order of n
3
element visits. How does doubling the number of elements affect the number of visits?
Question 76
Multiple Choice
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]; }
Question 77
Multiple Choice
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?
Question 78
Multiple Choice
Another name for linear search is ____ search.
Question 79
Multiple Choice
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?