Deck 19: Searching, Sorting and Big O

Full screen (f)
exit full mode
Question
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.
Use Space or
up arrow
down arrow
to flip the card.
Question
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.
Question
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.
Question
The linear search algorithm runs in ________time.

A)quadratic
B)O(n)
C)constant
D)nonlinear
Question
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.
Question
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.
Question
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.
Question
An O(n)algorithm is referred to as having a _______ run time.

A)constant
B)linear
C)quadratic
D)negative
Question
What is the efficiency of linear search?

A)O(1).
B)O(log n).
C)O(n).
D)O(n2).
Question
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.
Question
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.
Question
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.
Question
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
Question
What is the efficiency of selection sort?

A)O(n2).
B)O(n log n).
C)O(n).
D)O(1).
Question
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.
Question
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.
Question
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
Question
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.
Question
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.
Question
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
Question
What is the efficiency of merge sort?

A)O(log n).
B)O(n).
C)O(n log n).
D)O(n2).
Question
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.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/22
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 19: Searching, Sorting and Big O
1
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
2
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
3
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
4
The linear search algorithm runs in ________time.

A)quadratic
B)O(n)
C)constant
D)nonlinear
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
5
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.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
6
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.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
7
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.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
8
An O(n)algorithm is referred to as having a _______ run time.

A)constant
B)linear
C)quadratic
D)negative
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
9
What is the efficiency of linear search?

A)O(1).
B)O(log n).
C)O(n).
D)O(n2).
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
10
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.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
11
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.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
12
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.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
13
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
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
14
What is the efficiency of selection sort?

A)O(n2).
B)O(n log n).
C)O(n).
D)O(1).
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
15
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.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
16
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.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
17
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
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
18
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.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
19
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.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
20
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
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
21
What is the efficiency of merge sort?

A)O(log n).
B)O(n).
C)O(n log n).
D)O(n2).
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
22
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.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 22 flashcards in this deck.