Services
Discover
Homeschooling
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
Quiz 14: Sorting and Searching
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 61
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 62
Multiple Choice
Given an ordered array with 15 elements, how many elements must be visited in the worst case of binary search?
Question 63
Multiple Choice
Which of the following statements about running times of algorithms is correct?
Question 64
Multiple Choice
Another name for linear search is ____ search.
Question 65
Multiple Choice
Can you search the following array using binary search? Int[] A = {6, 5, 4, 2, 0, 1, -1, -17};
Question 66
Multiple Choice
The partial linear search method below is designed to search an array of String objects. Select the expression that would be needed to complete the method. public static int search(String[] a, String item) { For (int i = 0; i < a.length; i++) { If ( ____________________________ ) { Return i; } Return -1; } }
Question 67
Multiple Choice
The partial binary search method below is designed to search an array of String objects sorted in ascending order. Select the expression that would be needed to complete the method. public static int search(String[] a, int low, int high, String item) { If (low <= high) { Int mid = (low + high) / 2; Int result = ____________________________; If (result == 0) { Return mid; } Else if (result < 0) { Return search(a, mid + 1, high, item) ; } Else { Return search(a, low, mid - 1, item) ; } } Return -1; }
Question 68
Multiple Choice
Given an ordered array with 31 elements, how many elements must be visited in the worst case of binary search?
Question 69
Multiple Choice
The following code is an example of a ___ search. public static int search(int[] a, int v) { For (int i = 0; i < a.length; i++) { If (a[i] == v) { return i; } } Return -1; }
Question 70
Multiple Choice
A portion of your program includes the loop shown in the code snippet below to examine the elements of an array arr: Int count = 0; Int targetVal = 70; For (int i = 0; i < arr.length; i++) { If (arr[i] >= targetVal) { Count++; } } What can you conclude about the running time of this section of code?
Question 71
Multiple Choice
The analysis for the number of visits in a binary search begins with the equation, T(n) = T(n / 2) + 1. What does the number 1 represent in this equation?
Question 72
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 73
Multiple Choice
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?
Question 74
Multiple Choice
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?
Question 75
Multiple Choice
Suppose you have a phone number and need to find the address that it corresponds to. If there are 2,000,000 entries, how many do you expect to search in a printed phone directory before finding the address you are looking for?