# MCQ - Sorting in Data Structure

11. In the following scenarios, when will you use selection sort?

A. The input is already sorted

B. A large file has to be sorted

C. Large values need to be sorted with small keys

D. Small values need to be sorted with large keys

View Answer

Ans : C

Explanation: Selection is based on keys, hence a file with large values and small keys can be efficiently sorted with selection sort.

12. What is the worst case complexity of selection sort?

A. O(nlogn)

B. O(logn)

C. O(n)

D. O(n2)

View Answer

Ans :DC

Explanation: Selection sort creates a sub-list, LHS of the ‘min’ element is already sorted and RHS is yet to be sorted. Starting with the first element the ‘min’ element moves towards the final element.

13. What is the advantage of selection sort over other sorting techniques?

a) It requires no additional storage space

b) It is scalable

c) It works best for inputs which are already sorted

d) It is faster than any other sorting technique

View Answer

Ans : A

Explanation: Since selection sort is an in-place sorting algorithm, it does not require additional storage.

14. What is the average case complexity of selection sort?

A. O(nlogn)

B. O(logn)

C. O(n)

D. O(n2)

View Answer

Ans : D

Explanation: In the average case, even if the input is partially sorted, selection sort behaves as if the entire array is not sorted. Selection sort is insensitive to input.

15. What is the disadvantage of selection sort?

A. It requires auxiliary memory

B. It is not scalable

C. It can be used for small keys

D. None of the mentioned

View Answer

Ans : B

Explanation: As the input size increases, the performance of selection sort decreases.

16. The given array is arr = {3,4,5,2,1}. The number of iterations in bubble sort and selection sort respectively are,

A. 5 and 4

B. 4 and 5

C. 2 and 4

D. 2 and 5

View Answer

Ans : A

Explanation: Since the input array is not sorted, bubble sort takes 5 iterations and selection sort takes 4(n-1) iterations.

17. The given array is arr = {1,2,3,4,5}. (bubble sort is implemented with a flag variable)The number of iterations in selection sort and bubble sort respectively are,

A. 5 and 4

B. 1 and 4

C. 0 and 4

D. 4 and 1

View Answer

Ans : B

Explanation: Selection sort is insensitive to input, hence 4(n-1) iterations. Whereas bubble sort iterates only once to set the flag to 0 as the input is already sorted.

18.What is the best case complexity of selection sort?

A. O(nlogn)

B. O(logn)

C. O(n)

D. O(n2)

View Answer

Ans : D

Explanation: The best, average and worst case complexities of selection sort is O(n2).

(n-1) + (n-2) + (n-3) + …. + 1 = (n(n-1))/2 ~ (n2)/2.

19. What is an internal sorting algorithm?

A. Algorithm that uses tape or disk during the sort

B. Algorithm that uses main memory during the sort

C. Algorithm that involves swapping

D. Algorithm that are considered ‘in place’

View Answer

Ans : B

Explanation: As the name suggests, internal sorting algorithm uses internal main memory.

20.What is the worst case complexity of bubble sort?

A. O(nlogn)

B. O(logn)

C. O(n)

D. O(n2)

View Answer

Ans : D

Explanation: Bubble sort works by starting from the first element and swapping the elements if required in each iteration.

**Also Check : **

Discussion