# MCQ on Sorting Algorithm

1.Which of the following is not a stable sorting algorithm in its typical implementation.

a. Insertion Sort

b. Merge Sort

c. Quick Sort

d. Bubble Sort

Ans: quick Sort

2. Which of the following sorting algorithms in its typical implementation gives best performance when applied on an array which is sorted or almost sorted (maximum 1 or two elements are misplaced).

a. Insertion Sort

b. Merge Sort

c. Quick Sort

d. Bubble Sort

Ans: Insertion Sort

Question 2 Explanation:

c. Selection Sort

d. Bubble Sort

a. Insertion Sort

b. Merge Sort

c. Quick Sort

d. Bubble Sort

Ans: quick Sort

2. Which of the following sorting algorithms in its typical implementation gives best performance when applied on an array which is sorted or almost sorted (maximum 1 or two elements are misplaced).

a. Insertion Sort

b. Merge Sort

c. Quick Sort

d. Bubble Sort

Ans: Insertion Sort

Question 2 Explanation:

Insertion sort takes linear time when input array is sorted or almost sorted (maximum 1 or 2 elements are misplaced). All other sorting algorithms mentioned above will take more than lienear time in their typical implementation.

3. 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?

a. Insertion Sort

b. Merge Sortc. Selection Sort

d. Bubble Sort

Question 3 Explanation:

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

4. What is the worst case time complexity of insertion sort where position of the data to be inserted is calculated using binary search?

## No comments