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 Late Objects
Exam 14: Sorting and Searching
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 61
Multiple Choice
When your class implements a comparator object, you must implement the compare method. What must be true about the return value from this method when comparing two objects, a and b with a call to a.compare(b) ?
Question 62
Multiple Choice
When does quicksort's worst-case run-time behavior occur? I when the data is randomly initialized in the array II when the data is in ascending order III when the data is in descending order
Question 63
Multiple Choice
If an element is present in an array of length n, how many element visits, in the worst case, are necessary to find it using a linear search?
Question 64
Multiple Choice
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?
Question 65
Multiple Choice
Given an ordered array with 15 elements, how many elements must be visited in the worst case of binary search?
Question 66
Multiple Choice
Merge sort has a O(n log
2
(n) ) complexity. If a computer can sort 1,024 elements in an amount of time x, approximately how much longer will it take the computer to sort 1,024 times that many, or 1,048,576 elements?
Question 67
Multiple Choice
Which of the sorts in the textbook are based on the strategy of divide and conquer? I quicksort II mergesort III insertion sort
Question 68
Multiple Choice
If the array is already sorted, what is the performance of insertion sort?
Question 69
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 70
Multiple Choice
In Big-Oh notation, selection sort is a(n) ____ algorithm.
Question 71
Multiple Choice
The method checkArray examines an array arr: Public static boolean checkArray(int[] arr) { If (arr[0] >= arr[arr.length -1]) { Return true; } Return false; } What can you conclude about the running time of this section of code?