Deck 8: Sorting

Full screen (f)
exit full mode
Question
The number of comparisons for a selection sort is represented by the series: (n - 1) + (n - 2) + ... + 3 + 2 + 1
Use Space or
up arrow
down arrow
to flip the card.
Question
Insertion sort is considered a quadratic sort.
Question
With respect to selection sort, the number of comparisons is O(n).
Question
The improvement of Shell sort over insertion sort is much more significant for small arrays.
Question
The method sort(int[] items), in class java.util.Arrays, sorts the array item in ascending order.
Question
A class that implements the Comparable interface must define a(n) ____________________ method that determines the natural ordering of its objects.
Question
____________________ sorts an array by making several passes through the array, selecting the next smallest item each time and placing it where it belongs in the array.
Question
In the best case, selection sort makes O(______) comparisons.
Question
With respect to merge sort, additional space usage is O(___________________).
Question
The idea behind ____________________ sort is to sort many smaller subarrays using insertion sort before sorting the entire array.
Question
____________________ sort has O(n3/2) or better performance.
Question
Whenever a recursive method is called, a copy of the local variables is saved on the run-time ____________________.
Question
The Java API ____________________ provides a class Arrays with several overloaded sort methods for different array types.
Question
Insertion sort is an example of a(n) ____________________ sorting algorithm.
Question
You can think of the ____________________ sort as a divide-and-conquer approach to insertion sort.
Question
The following represents the ____ sort algorithm.
Set the initial value of gap to n / 2.
While gap > 0
For each array element from position gap to the last element
Insert this element where it belongs in its subarray.
If gap is 2, set it to 1.
Else gap = gap/2.2.

A) Shell
B) Heap
C) Insertion
D) Quick
Question
The following is the ____ algorithm.
Access the first item from both sequences.
While not finished with either sequence
Compare the current items from the two sequences, copy the smaller current item to the output sequence, and
Access the next item from the input sequence whose item was copied
Copy any remaining items from the first sequence to the output sequence.
Copy any remaining items from the second sequence to the output sequence.

A) Shell sort
B) Selection sort
C) Merge sort
D) Heapsort
Question
The following is the ____ algorithm
For fill = 0 to n - 2 do
Set posMin to the subscript of the smallest item starting at subscript fill.
Exchange the item at posMin with the one at fill.

A) Heapsort
B) Insertion sort
C) Selection sort
D) Merge sort
Question
In merge sort, the total effort to reconstruct the sorted array through merging is ____.

A) O(1)
B) O(log2n)
C) O(n log n)
D) O(n2)
Question
Which of the following sorts is not O(n lg(n))

A) selection
B) heap
C) merge
Question
The best sorting algorithms provide ____ average-case behavior and are considerably faster for large arrays.

A) O(1)
B) O(n)
C) O(n2)
D) O(n log n)
Question
Which of the following generally gives the worst performance?

A) Selection sort
B) Bubble sort
C) Insertion sort
D) Shell sort
Question
Shell sort is ____ if successive powers of 2 are used for gap.

A) O(log n)
B) O(1)
C) O(log2n)
D) O(n2)
Question
The following represents the algorithm for ____ sort.
For each array element from the second (nextPos = 1) to the last
Insert the element at nextPos where it belongs in the array, increasing
The length of the sorted subarray by 1 element.

A) merge
B) shell
C) selection
D) insertion
Question
The following is the ____ algorithm.
Build a heap by rearranging the elements in an unsorted array.
While the heap is not empty
Remove the first item from the heap by swapping it with the last item in the heap
And restoring the heap property.

A) Quicksort
B) Bubble sort
C) Merge sort
D) In-Place Heapsort
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/25
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 8: Sorting
1
The number of comparisons for a selection sort is represented by the series: (n - 1) + (n - 2) + ... + 3 + 2 + 1
True
2
Insertion sort is considered a quadratic sort.
True
3
With respect to selection sort, the number of comparisons is O(n).
False
4
The improvement of Shell sort over insertion sort is much more significant for small arrays.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
5
The method sort(int[] items), in class java.util.Arrays, sorts the array item in ascending order.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
6
A class that implements the Comparable interface must define a(n) ____________________ method that determines the natural ordering of its objects.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
7
____________________ sorts an array by making several passes through the array, selecting the next smallest item each time and placing it where it belongs in the array.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
8
In the best case, selection sort makes O(______) comparisons.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
9
With respect to merge sort, additional space usage is O(___________________).
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
10
The idea behind ____________________ sort is to sort many smaller subarrays using insertion sort before sorting the entire array.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
11
____________________ sort has O(n3/2) or better performance.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
12
Whenever a recursive method is called, a copy of the local variables is saved on the run-time ____________________.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
13
The Java API ____________________ provides a class Arrays with several overloaded sort methods for different array types.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
14
Insertion sort is an example of a(n) ____________________ sorting algorithm.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
15
You can think of the ____________________ sort as a divide-and-conquer approach to insertion sort.
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
16
The following represents the ____ sort algorithm.
Set the initial value of gap to n / 2.
While gap > 0
For each array element from position gap to the last element
Insert this element where it belongs in its subarray.
If gap is 2, set it to 1.
Else gap = gap/2.2.

A) Shell
B) Heap
C) Insertion
D) Quick
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
17
The following is the ____ algorithm.
Access the first item from both sequences.
While not finished with either sequence
Compare the current items from the two sequences, copy the smaller current item to the output sequence, and
Access the next item from the input sequence whose item was copied
Copy any remaining items from the first sequence to the output sequence.
Copy any remaining items from the second sequence to the output sequence.

A) Shell sort
B) Selection sort
C) Merge sort
D) Heapsort
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
18
The following is the ____ algorithm
For fill = 0 to n - 2 do
Set posMin to the subscript of the smallest item starting at subscript fill.
Exchange the item at posMin with the one at fill.

A) Heapsort
B) Insertion sort
C) Selection sort
D) Merge sort
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
19
In merge sort, the total effort to reconstruct the sorted array through merging is ____.

A) O(1)
B) O(log2n)
C) O(n log n)
D) O(n2)
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
20
Which of the following sorts is not O(n lg(n))

A) selection
B) heap
C) merge
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
21
The best sorting algorithms provide ____ average-case behavior and are considerably faster for large arrays.

A) O(1)
B) O(n)
C) O(n2)
D) O(n log n)
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
22
Which of the following generally gives the worst performance?

A) Selection sort
B) Bubble sort
C) Insertion sort
D) Shell sort
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
23
Shell sort is ____ if successive powers of 2 are used for gap.

A) O(log n)
B) O(1)
C) O(log2n)
D) O(n2)
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
24
The following represents the algorithm for ____ sort.
For each array element from the second (nextPos = 1) to the last
Insert the element at nextPos where it belongs in the array, increasing
The length of the sorted subarray by 1 element.

A) merge
B) shell
C) selection
D) insertion
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
25
The following is the ____ algorithm.
Build a heap by rearranging the elements in an unsorted array.
While the heap is not empty
Remove the first item from the heap by swapping it with the last item in the heap
And restoring the heap property.

A) Quicksort
B) Bubble sort
C) Merge sort
D) In-Place Heapsort
Unlock Deck
Unlock for access to all 25 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 25 flashcards in this deck.