Exam 8: Sorting
Exam 1: Object-Oriented Programming and Class Hierarchies41 Questions
Exam 2: Lists and the Collections Framework35 Questions
Exam 3: Testing and Debugging25 Questions
Exam 4: Stacks and Queues28 Questions
Exam 5: Recursion25 Questions
Exam 6: Trees25 Questions
Exam 7: Sets and Maps27 Questions
Exam 8: Sorting25 Questions
Exam 9: Self-Balancing Search Trees28 Questions
Exam 10: Graphs25 Questions
Exam 11: Introduction to Java25 Questions
Exam 12: Overview of UML25 Questions
Select questions type
A class that implements the Comparable interface must define a(n) ____________________ method that determines the natural ordering of its objects.
Free
(Short Answer)
5.0/5
(35)
Correct Answer:
compareTo
You can think of the ____________________ sort as a divide-and-conquer approach to insertion sort.
Free
(Short Answer)
4.9/5
(33)
Correct Answer:
Shell
Insertion sort is considered a quadratic sort.
Free
(True/False)
4.8/5
(46)
Correct Answer:
True
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.
(Multiple Choice)
4.8/5
(36)
Which of the following generally gives the worst performance?
(Multiple Choice)
4.8/5
(47)
____________________ 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.
(Short Answer)
4.9/5
(37)
Whenever a recursive method is called, a copy of the local variables is saved on the run-time ____________________.
(Short Answer)
4.9/5
(43)
The idea behind ____________________ sort is to sort many smaller subarrays using insertion sort before sorting the entire array.
(Short Answer)
5.0/5
(44)
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.
(Multiple Choice)
5.0/5
(35)
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.
(Multiple Choice)
4.7/5
(45)
With respect to merge sort, additional space usage is O(___________________).
(Short Answer)
4.8/5
(41)
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.
(Multiple Choice)
4.7/5
(31)
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.
(Multiple Choice)
4.8/5
(41)
Shell sort is ____ if successive powers of 2 are used for gap.
(Multiple Choice)
5.0/5
(42)
The Java API ____________________ provides a class Arrays with several overloaded sort methods for different array types.
(Short Answer)
4.8/5
(45)
With respect to selection sort, the number of comparisons is O(n).
(True/False)
4.8/5
(34)
The number of comparisons for a selection sort is represented by the series: (n - 1) + (n - 2) + ... + 3 + 2 + 1
(True/False)
4.8/5
(34)
Showing 1 - 20 of 25
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)