Top MCQs on SelectionSort Algorithm with Answers

The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning. The algorithm maintains two subarrays in a given array … More on Selection Sort
Selection Sort

Selection Sort

Question 1

Consider a situation where swap operation is very costly. Which of the following sorting algorithms should be preferred so that the number of swap operations are minimized in general?

Cross

Heap Sort

Tick

Selection Sort

Cross

Insertion Sort

Cross

Merge Sort



Question 1-Explanation: 

Selection sort makes O(n) swaps which is the minimum among all sorting algorithms mentioned above.

Hence Option(B) is the correct answer.

Question 2

Which sorting algorithm will take least time when all elements of input array are identical? Consider typical implementations of sorting algorithms.

Tick

Insertion Sort

Cross

Heap Sort

Cross

Merge Sort

Cross

Selection Sort



Question 2-Explanation: 

The insertion sort will O(n) time when input array is already sorted.

Question 3

Which of the following sorting algorithms has the lowest worst-case complexity?

Tick

Merge Sort

Cross

Bubble Sort

Cross

Quick Sort

Cross

Selection Sort



Question 3-Explanation: 

Worst-case complexities for the above sorting algorithms are as follows:

  • Merge Sort: O(n*log(n))
  • Bubble Sort: O(n2)
  • Quick Sort: O(n2)
  • Selection Sort: O(n2)
Question 4
Which is the correct order of the following algorithms with respect to their time Complexity in the best case ?
Cross
Merge sort > Quick sort >Insertion sort > selection sort
Tick
insertion sort < Quick sort < Merge sort < selection sort
Cross
Merge sort > selection sort > quick sort > insertion sort
Cross
Merge sort > Quick sort > selection sort > insertion sort


Question 4-Explanation: 
In best case, 

Quick sort: O (nlogn) 
Merge sort: O (nlogn)
Insertion sort: O (n)
Selection sort: O (n^2)  
Question 5
Which one of the following in-place sorting algorithms needs the minimum number of swaps?
Cross
Insertion Sort
Cross
Quick Sort
Cross
Heap Sort
Tick
Selection Sort


Question 5-Explanation: 
Selection Sort is an in-place algorithm having minimum number of swaps. It works on greedy approach and takes O(n) swaps to sort the array of n elements. Refer: GATE-CS-2006 | Question 14
Question 6
How many comparisons are needed to sort an array of length 5 if a straight selection sort is used and array is already in the opposite order?
Cross
1
Cross
5
Tick
10
Cross
20


Question 6-Explanation: 
Consider the array: 5 4 3 2 1 1st iteration will compare 4 numbers with the 5 2nd iteration will compare 3 numbers with the 4 3rd iteration will compare 2 numbers with the 3 4th iteration i will compare 1 number with the 2 So, the total number of comparisons is 4 + 3 + 2 + 1 = 10 It can be viewed as the sum of the sequence of the first (n-1) numbers starting by 1 S = ((1 + (n-1) )*(n-1) )/2 S = 10 Option (C) is correct.
There are 6 questions to complete.
 

Coding practice for sorting.

 

  • Last Updated : 27 Sep, 2023

Share your thoughts in the comments
Similar Reads