Logo of the Augustana Faculty of the University of Alberta

COMPUTING SCIENCE 210
Algorithm Analysis and Data Structures


Review Questions — Sorting and Selection



Merge Sort

  1. How much additional space does merge sort require in order to sort an input sequence of size n?

  2. Suppose we are given two n-element sorted sequences A and B, each of which may contain duplicate entries. Describe a O(n)-time method for computing a sequence representing the set A ∪ B (with no duplicates).

Quicksort

  1. Show the result after quicksort partitions the following list of elements using the first element of the array as the pivot.

        12  18   7   1  15   7   5   3   4  20   6   2
  2. Why might it be preferable to choose the pivot for quicksort's partitioning algorithm from the center of the array of values to be sorted, rather than from one of the ends of the array?

  3. Describe how the median-of-three pivot selection algorithm works.

Lower Bound on Sorting

  1. Why does the Ω(n log n) lower bound not apply to all sorting algorithms? Describe one of the "exempt" algorithms.

Bucket Sort and Radix Sort

  1. Show the result after each stage of sorting the following list of ID numbers using radix sort.

    4312   2126   2415   1153   3353   1223   2422   4112   1266
  2. Radix sort is a O(n) algorithm; quicksort is a O(n log n) algorithm. While n log n > n for n >= 2, quicksort is still faster than radix sort for some problems involving fixed-length keys. Why?

Shell sort

  1. What is the relationship between Shell sort and insertion sort?

Comparison of Sorting Algorithms

  1. Compare merge sort with quicksort in terms of running time and space usage. Indicate the Big-O performance bound for each algorithm.

Selection

  1. What is the expected Big-O running time of the randomized quick-select algorithm?

Copyright © 2005 Jonathan Mohr