Return to main page
Design and Analysis of Algorithms
CMSC 441 - Fall 2021
Homework 4
Due: Wednesday, November 3rd by 11:59:00 PM EDT (on blackboard)
Musical Selection: Fantaisie Impromptu Op. 66 — Frédéric Chopin
Respond to the questions below with appropriate responses as directed.
-
(20 points) Prove that Counting Sort as described in-class (or in the textbook) is a
stable sort. If the loop at the end of the sort counted up instead of down, would the
sort still be stable?
-
(10 points) Why does the implementation of Bucket Sort described in-class (or in the textbook) have a worst-case
running time of O(n2)? How could it be modified to change its worst-case running
time to O(n lg n)?
-
(20 points) Provide a pseudocode implementation of a function to merge two skip lists
into one. Your implementation must be more efficient than simply iterating through one
list and inserting its elements into the other list. You may implement your solution in
a manner such that one or both of the input lists is no longer valid after the call to
your function. Also, you may keep all nodes the same size that they were in their previous
list, if that is helpful to you.
Some questions adapted from "Introduction to Algorithms" 3rd edition.
Last modified Wednesday, 27-Oct-2021 18:40:24 EDT