# Interview Questions and Quiz on Selection Sort Set 2

## This quiz series is for testing your knowledge about selection sort algorithm of data structures. The questions are arranged in a random order, but all of them are on the same topic. This is quiz no. 2 in this series.

Last Reviewed and Updated on February 7, 2020
Posted by Parveen(Hoven),
Aptitude Trainer and Software Developer

## Quiz Questions

Each question has four choices. More than one options can be correct. When you have finished the quiz, click the button at the end of the questions to view the result, and the solutions and answers.

### Question 1

Selection sort is
A
in-place
B
non in-place
C
out place
D
None
Soln.
Ans: A

### Question 2

Which type of growth does the selection sort have
A
quadratic order of growth
B
linear order of growth
C
loglinear order of growth
D
none of them
Soln.
Ans: A

### Question 3

A sorting algorithm that repeatedly looks through remaining items to find the least one and moves it to its final location is
A
Quick Sort
B
Bubble Sort
C
Selection Sort
D
Merge Sort
Soln.
Ans: C

### Question 4

In an ascending ____ sort the first element in the array is assumed to be the smallest.
A
bubble
B
swap
C
selection
D
insertion
Soln.
Ans: C

### Question 5

For each i from 1 to n - 1, there are _______ comparisons for selection sort.
A
n
B
n - i
C
i
D
n - 1
Soln.
Ans: B
For each i from 1 to n - 1, there is one exchange and n - i comparisons, so there is a total of n -1 exchanges and (n -1) + (n -2) + . . . + 2 + 1 = n(n -1)/2 comparisons. These observations hold no matter what the input data is.

### Question 6

How many comparisons are performed in the second pass of the selection sort algorithm?
A
n - 1
B
n - 2
C
n
D
None of the above
Soln.
Ans: B

### Question 7

For each i from 1 to n - 1, there are _______ comparisons for selection sort.
A
n
B
n - i
C
i
D
n - 1
Soln.
Ans: B
For each i from 1 to n - 1, there is one exchange and n - i comparisons, so there is a total of n -1 exchanges and (n -1) + (n -2) + . . . + 2 + 1 = n(n -1)/2 comparisons. These observations hold no matter what the input data is.

### Question 8

The worst case space complexity of selection sort is:
A
O(n2)
B
O(2n)
C
O(n) total, O(1) auxiliary
D
O(n log n)
Soln.
Ans: C

### Question 9

Selection sort is suitable for which type of list.
A
Large
B
Small
C
Depends on elements
D
None
Soln.
Ans: B

### Question 10

Selection sort and quick sort both fall into the same category of sorting algorithms. What is this category?
A
O(n log n) sorts
B
Divide-and-conquer sorts
C
Interchange sorts
D
Average time is quadratic.
Soln.
Ans: B

## My C/C++ Videos on Youtube

Here is the complete playlist for video lectures and tutorials for the absolute beginners. The language has been kept simple so that anybody can easily understand them. I have avoided complex jargon in these videos.