CSD_PT7_Sort
Select the most correct statement about complexity of mergesort Select one: A/Both best, worst cases and average case are O(nlogn) B/Similar to quicksort C/The best case and the average case is O(nlogn), and worst case is O (n^2) D/The best case is O ( n ), and the average case is O(nlogn)
A
Select the most correct statement about complexity of selection sort Select one: A/Both best and worst cases are O(n^2) B/The best case is O ( n ), and the worst case is O(n^2) C/The best case is O ( n ), and the average case is O(n^2) D/The best case is O ( n ), and the average case is O(nlogn)
A
The following is the main part of bubble sort pseudocode: do swapped := false for i := 0 to n-2 if a[i] > a[i+1] then swap(a[i],a[i+1]) swapped := true end if end for while swapped Consider the list of ten integers below: 5, 3, 10, 11, 1, 8, 0, 2, 6, 4 What is the list after the FIRST iteration (for i = 0 to n-2) in a bubble sort? (sorting from smallest to largest). Select one: A/3, 5, 10, 1, 8, 0, 2, 6, 4, 11 B/3, 5, 10, 0, 1, 8, 2, 6, 4, 11 C/3, 5, 10, 8, 1, 0, 2, 6, 4, 11 D/3, 5, 10, 1, 8, 0, 2, 4, 6, 11
A
The following is the main part of selection sort pseudocode: for i := 0 to n-2 // large loop find a[k], where a[k] = min {a[i], a[i+1],...,a[n-1]} if k # i then swap a[i] with a[k] end for Consider the list of ten integers below: 5, 3, 9, 10, 1, 7, 0, 2, 6, 4 What is the list after the FIRST TWO iterations of the large loop in a selection sort? (sorting from smallest to largest). Select one: A/0, 1, 9, 10, 3, 7, 5, 2, 6, 4 B/0, 1, 9, 10, 3, 7, 5, 3, 6, 4 C/0, 1, 9, 10, 2, 7, 5, 3, 6, 4 D/0, 2, 9, 10, 1, 7, 5, 3, 6, 4
A
In the average-case, quicksort is __________. Select one: A/O(n^2) B/O(nlogn) C/O(1) D/O ( n)
B
In the worst case, insertion sort algorithm is _______. Select one: A/O ( n) B/O(n^2) C/O(nlogn) D/O(n^3)
B
Select the most correct statement about complexity of heap sort Select one: A/Similar to quicksort B/Similar to mergesort C/The best case and the average case is O(nlogn), and worst case is O (n^2) D/The best case is O ( n ), and the average case is O(nlogn)
B
Select the most correct statement about complexity of insertion sort Select one: A/Both best and worst cases are O(n^2) B/The best case is O ( n ), and the worst case is O(n^2), and average case is O (n^2) C/The best case is O ( n ), and the worst case is O(nlogn) D/The best case is O ( n ), and the average case is O(nlogn)
B
Suppose you are building a Java class named Student, which encapsulates a student's information. To provide comparison facility for this class, which implementation should be used? Select one: A/Student extends Comparator B/Student implements Comparable C/Student implements Comparator D/Student extends Comparable
B
Partitioning is a technique used in quicksort. The following is a partition pseudocode: partition the array a from index low to index up x := a[low], i=low, j=up do increase i and stop at i, where a[i]>x decrease j and stop at j, where a[j]<=x if(i<j) swap a[i] with a[j] while(i<j) swap a[0] with a[j] Consider the list of eight integers (n=8) below: 6, 3, 10, 11, 8, 2, 7, 5 What is the list after it is partitioned by the first step of quicksort (low = 0, up = n-1)? (sorting from smallest to largest). Select one: Select one: A/2, 3, 5, 6, 8, 7, 10, 11 B/2, 3, 6, 5, 8, 11, 7, 10 C/2, 3, 5, 6, 8, 11, 7, 10 D/2, 3, 5, 6, 7, 8, 11, 10
C
Select the most correct statement about complexity of bubble sort Select one: A/Both best and worst cases are O(n^2) B/Similar selection sort C/Similar to insertion sort D/The best case is O ( n ), and the average case is O(nlogn)
C
Select the most correct statement about complexity of quicksort Select one: A/Both best, worst cases and average case are O(nlogn) B/Similar to mergesort C/The best case and the average case is O(nlogn), and worst case is O (n^2) D/The best case is O ( n ), and the average case is O(nlogn)
C
What is the best case of bubble sort algorithm? Select one: A/None of the other choices B/When the array is sorted in the reversed order. C/When an array to be sorted is already sorted. D/There is no best case for bubble sort algorithm. All cases are equal.
C
Partitioning is a technique used in __________. Select one: A/Insertion sort B/It is not used in sorting algorithms. C/Bubble sort D/Quick sort E/Selection sort
D
The following is the main part of insertion sort pseudocode: for i := 1 to n-1 insert a[i] into sorted sublist {a[0],...,a[i-1]} so that the sortedness is still kept. end for Select the most correct solution: Consider the list of ten integers below: 15, 4, 2, 11, 9, 7, 12, 3, 7, 5 What is the list after the FIRST TWO steps of insertion sort? (sorting from smallest to largest). Select one: A/2, 3, 15, 11, 9, 7, 12, 4, 7, 5 B/2, 3, 4, 11, 9, 7, 12, 15, 7, 5 C/2, 4, 11, 9, 7, 12, 3, 7, 5, 15 D/2, 4, 15, 11, 9, 7, 12, 3, 7, 5
D