# Sorting Algorithm Quiz & Answers

1. What of the following requires the most memory space?

a. Quick Sort
b. Bubble Sort
c. Merge Sort
d. Insertion Sort
e. Selection Sort

2. What sorting algorithm is canonically the best for data sets that cannot reside in memory (and must be persisted to disk)?

b. Bubble sort
c. Insertion sort
d. Selection sort
e. Merge sort
f. Quick sort

Answer: E. Merge sort. Source page 149 of Programming Interviews Exposed.

3. Which sorting algorithm does this describe?

Without doing comparisons among the elements, iteratively placing elements into buckets those items based on the least significant digit, then placing them into sub-buckets based on the second least significant digit, until it reaches the most significant digit.

b. Bubble sort
c. Insertion sort
d. Selection sort
e. Merge sort
f. Quick sort

4. Which sorting algorithm does this describe?

Take non-overlapping partitions of the data set, order them individually, then build a larger ordered partition from the smaller sub-portions until you have an ordered result.

b. Bubble sort
c. Insertion sort
d. Selection sort
e. Merge sort
f. Quick sort

Answer: E. Source: Pages 148 and 149 of Programming Interviews Exposed.

5. Which sorting algorithm does this describe?

Gradually build a sorted array by taking one random element at a time from the source array. Each new element is placed in order via comparison with sorted elements in what will be the final result.

b. Bubble sort
c. Insertion sort
d. Selection sort
e. Merge sort
f. Quick sort

Source: Page 145 of Programming Interviews Exposed.

6. Which sorting algorithm does this describe?

Take one element to be a pivot value. Place all bigger and equal elements to the left of the pivot value and all the smaller values to the right. To sort these smaller sub-partitions to the left and right, take one element to be a pivot value. Place all bigger or equal elements of this subpartition to the right of this pivot value and elements that are smaller to the left.

b. Bubble sort
c. Insertion sort
d. Selection sort
e. Merge sort
f. Quick sort

Answer: F. Quicksort. Source: Page 146 of Programming Interviews Exposed.

7. Which sorting algorithm does this describe?

Find the smallest element then move it to the far left. Find the second smallest element, then move it to the second-to-most-left position. Find the third smallest element…

b. Bubble sort
c. Insertion sort
d. Selection sort
e. Merge sort
f. Quick sort

Answer: D. Source: Page 144 of Programming Interviews Exposed.

8. In the I.T. industry it is common to code various sorting algorithms in the workplace.

True
False

Answer: False. Source page 143 of Programming Interviews Exposed.

9. A comparison-based sorting algorithm in a worst case scenario can have which of the following runtime complexities?

a. O(N)
b. O(n log n)
c. O(n^2)
d. None of the above

Answer: B. Source: Page 144 of Programming Interviews Exposed by Mongan, Kindler and Giguere.

10. What is the average runtime complexity of insertion sort?

a. O(n)
b. O(n log n)
c. O(n^2)
d. None of the above.

Answer: C. Source page 146 of Programming Interviews Exposed by Mongan, Kindler and Giguere.