Data Structures & Algorithms Multiple Choice Questions on “Cycle Sort”.
1. Which of the following is an example of an unstable sorting algorithm? Answer: a 2. What is the worst case time complexity of cycle sort? Answer: d 3. What is the auxiliary space requirement of cycle sort? Answer: b 4. What is the best case time complexity of cycle sort? 5. What is the average case time complexity of cycle sort? Answer: a 6. Cycle sort is an adaptive sorting algorithm. 7. Which of the following sorting algorithm is in-place? Answer: b 8. Which of the following is an advantage of cycle sort? Answer: c 9. Cycle sort is a comparison based sort. Answer: a 10. Which of the following sorting algorithm uses the method of insertion? Answer: a 11. How many write operations will be required to sort the array arr={2,4,3,5,1} using cycle sort? Answer: a 12. Which of the following algorithm is best suited for the case where swap operation is expensive? Answer: b and Answers.
a) cycle sort
b) insertion sort
c) bubble sort
d) merge sort
Clarification: Out of the given options only cycle sort is an unstable sorting algorithm. This implies that the relative position of equal valued elements in the input and sorted array does not remain the same when we use cycle sort.
a) O(n)
b) O(log n)
c) O(n log n)
d) O(n2)
Clarification: The worst case performance of cycle sort is O(n2). It is because it has to make n comparisons for each element of the array.
a) O(n)
b) O(1)
c) O(log n)
d) O(n log n)
Clarification: Cycle sort requires an auxiliary space of O(1). So this makes it an in-place sorting algorithm.
a) O(n2)
b) O(n)
c) O(n log n)
d) O(1)
Answer: a
Clarification: Best case time complexity of cycle sort is O(n2). This shows that cycle sort is not an adaptive sorting algorithm and thus makes it undesirable when the given array is already almost sorted.
a) O(n2)
b) O(n log n)
c) O(log n)
d) O(n)
Clarification: The average case performance of cycle sort is O(n2). It is because it has to make n comparisons for each element of the array.
a) true
b) false
Answer: b
Clarification: The time complexity of cycle sort is O(n2) in any case. So cycle sort algorithm is not adaptive, as it will take the same time to sort an already sorted array and any other randomly arranged array.
a) Merge sort
b) Cycle sort
c) Counting sort
d) Radix sort
Clarification: Cycle sort has an auxiliary space complexity of O(1). So it qualifies to be an in-place sort. All other given options are not in place sorting algorithm.
a) it can sort large arrays efficiently
b) it has a low time complexity
c) it requires minimal write operations
d) it is an adaptive sorting algorithm
Clarification: Cycle sort is a slow sorting algorithm as compared to quick sort, merge sort etc. and is also not adaptive. But it offers an advantage that it performs minimal write operations which can be very useful in a situation where the write operation is expensive.
a) true
b) false
Clarification: Cycle sort is a comparison based sorting algorithm. This is because it compares elements in order to sort them.
a) cycle sort
b) bubble sort
c) quick sort
d) selection sort
Clarification: Cycle sort is the only algorithm from the given ones that uses the method of insertion. Other than this, insertion sort also uses the method of insertion for sorting.
a) 4
b) 5
c) 6
d) 3
Clarification: Cycle sort requires a minimum number of write operations in order to sort a given array. So in this case, only 4 write operations will be required.
a) bubble sort
b) cycle sort
c) cocktail sort
d) merge sort
Clarification: Cycle sort is a slow sorting algorithm but it requires a minimum number of write operations in order to sort a given array. So it is useful when the write/swap operation is expensive.