Engineering Questions with Answers - Multiple Choice Questions

Home » MCQs » Chemical Engineering » Quicksort MCQ’s – 1

# Quicksort MCQ’s – 1

Which of the following sorting algorithms is the fastest?

a) Merge sort

b) Quick sort

c) Insertion sort

d) Shell sort

**
View Answer**

Answer: b

Explanation: Quick sort is the fastest known sorting algorithm because of its highly optimized inner loop.

Quick sort follows Divide-and-Conquer strategy.

a) True

b) False

**
View Answer**

Answer: a

Explanation: In quick sort, the array is divided into sub-arrays and then it is sorted (divide-and-conquer strategy).

What is the worst case time complexity of a quick sort algorithm?

a) O(N)

b) O(N log N)

c) O(N^{2})

d) O(log N)

**
View Answer**

Answer: c

Explanation: The worst case performance of a quick sort algorithm is mathematically found to be O(N^{2}).

Which of the following methods is the most effective for picking the pivot element?

a) first element

b) last element

c) median-of-three partitioning

d) random element

**
View Answer**

Answer: c

Explanation: Median-of-three partitioning is the best method for choosing an appropriate pivot element. Picking a first, last or random element as a pivot is not much effective.

Find the pivot element from the given input using median-of-three partitioning method.

8, 1, 4, 9, 6, 3, 5, 2, 7, 0.

a) 8

b) 7

c) 9

d) 6

**
View Answer**

Answer: d

Explanation: Left element=8, right element=0,

Centre=[position(left+right)/2]=6.

Which is the safest method to choose a pivot element?

a) choosing a random element as pivot

b) choosing the first element as pivot

c) choosing the last element as pivot

d) median-of-three partitioning method

**
View Answer**

Answer: a

Explanation: This is the safest method to choose the pivot element since it is very unlikely that a random pivot would consistently provide a poor partition.

What is the average running time of a quick sort algorithm?

a) O(N^{2})

b) O(N)

c) O(N log N)

d) O(log N)

**
View Answer**

Answer: c

Explanation: The best case and average case analysis of a quick sort algorithm are mathematically found to be O(N log N).

Which of the following sorting algorithms is used along with quick sort to sort the sub arrays?

a) Merge sort

b) Shell sort

c) Insertion sort

d) Bubble sort

**
View Answer**

Answer: c

Explanation: Insertion sort is used along with quick sort to sort the sub arrays.

It is used only at the end.

Quick sort uses join operation rather than merge operation.

a) true

b) false

**
View Answer**

Answer: a

Explanation: Quick sort uses join operation since join is a faster operation than merge.

How many sub arrays does the quick sort algorithm divide the entire array into?

a) one

b) two

c) three

d) four

**
View Answer**

Answer: b

Explanation: The entire array is divided into two partitions, 1st sub array containing elements less than the pivot element and 2nd sub array containing elements greater than the pivot element.

Which is the worst method of choosing a pivot element?

a) first element as pivot

b) last element as pivot

c) median-of-three partitioning

d) random element as pivot

**
View Answer**

Answer: a

Explanation: Choosing the first element as pivot is the worst method because if the input is pre-sorted or in reverse order, then the pivot provides a poor partition.

Which among the following is the best cut-off range to perform insertion sort within a quick sort?

a) N=0-5

b) N=5-20

c) N=20-30

d) N>30

**
View Answer**

Answer: b

Explanation: A good cut-off range is anywhere between N=5 and N=20 to avoid nasty degenerate cases.