E19 - M
What is the efficiency of selection sort? a. O(n2). b. O(n log n). c. O(n). d. O(1).
a
A searching algorithm that's O(1)________. a. requires one comparison b. does not necessarily require only one comparison c. can search only an array of one item. d. None of the above.
b
Big O notation is concerned with the growth rate of algorithm run times, so ________. a. constants are dominant b. constants are ignored c. constant terms are emphasized d. constants with large values are more important than those with low values
b
Different sorting algorithms on a particular array produce the same result; the choice of algorithm affects ________ of the program that implements the algorithm. a. only the run time b. the run time and the memory use c. only the memory use d. neither the run time nor the memory use
b
How many comparisons will the linear search algorithm make if the search key is not in an array of 10 elements? a. 0. b. 10. c. 9. d. 5.
b
The linear search algorithm runs in ________time. a. quadratic b. O(n) c. constant d. nonlinear
b
Using a binary search, what is the maximum number of comparisons required to find a search key in a 31-element sorted array? a. 4. b. 5. c. 32. d. 1.
b
What does each iteration of the insertion sort algorithm do? a. Each iteration takes the next smallest element and inserts it at the beginning of the array. b. Each iteration takes the next element in the unsorted portion of the array and inserts it into the sorted portion. c. Sorted subarrays are inserted into the larger array. d. Each iteration determines the location of a pivot and inserts it into place.
b
Which of the following is not a name for a big O run time? a. Constant run time. b.Variable run time. c. Linear run time. d. Quadratic run time.
b
Big O notation describes ________. a. the amount of memory required by an algorithm. b. the difficulty of writing an algorithm to solve a specific problem. c. an algorithm's efficiency in terms of the work required to solve a problem. d. the length of an algorithm for solving a specific problem.
c
The worst case in linear search is that every element must be checked to determine whether the search key exists, which occurs if the search key ________. a. is the last array element b. is not present c. is the last array element or is not present d. None of the above.
c
What is the base case for the recursive merge sort algorithm? a. Any array that is already sorted. b. A two-element array. c. A one-element array. d. A zero-element array.
c
What is the efficiency of linear search? a. O(1). b. O(log n). c. O(n). d. O(n2).
c
What is the efficiency of merge sort? a. O(log n). b. O(n). c. O(n log n). d. O(n2).
c
Which of the following is a negative of binary search? a. It requires significantly more memory than linear search. b. It is slower than linear search. c. The data must be in sorted order. d. None of the above.
c
Which of the following sorting algorithms is the fastest? a. Selection sort. b. Insertion sort. c. Merge sort. d. They all run at roughly the same speed.
c
Which of the following statements is true? a. The binary search algorithm is less efficient than the linear search, but it requires that the array be sorted. b. The binary search algorithm is more efficient than the linear search, but it requires that the array be unsorted. c. The binary search algorithm is more efficient than the linear search, but it requires that the array be sorted. d. The binary search algorithm is less efficient than the linear search, but it requires that the array be unsorted.
c
Big O highlights ________ factors and ignores terms that become unimportant with ________ n values. a. insignificant, low b. insignificant, high c. dominant, low d. dominant, high
d
How much faster is insertion sort with a 15-element array than with a 60-element array? a. 60 times. b. 4 times. c.15 times. d. 19 times.
d
What does the first pass of selection sort do? a. Splits the array into two approximately equal pieces. b. Orders the first two elements of the array. c. Partitions the array into two unequal pieces depending on whether each element in the array is greater or less that some pivot element. d. Locates the smallest element in the array and swaps it into the zeroth position.
d
What is the term used for binary search's run time? a. Linear run time. b. Quadratic run time. c. Constant run time. d. Logarithmic run time.
d
Which of the following is a way to sort data? a. Alphabetically. b. In increasing numerical order. c. Based on an account number. d. All of the above.
d