UMBC CMSC641, Design & Analysis of Algorithms, Fall 1997

Homework 1

Due: Wednesday, September 10, 1997

  1. Problem 7-2, page 152.

  2. Exercise 18.1-3, page 360.

  3. Railroad Yard Switching: We are given as input a permutation p(1), p(2), ..., p(n) of 1, 2, ..., n. We have two stacks, A and B, and we want to sort the permutation into increasing order using operations of the form: It may help to visualize this as a railroad yard switching problem:

    Some permutations can be sorted and others can't. For example, 2314 can, 2341 can't, 5274163 can't and 78524163 can. Design an algorithm that either reports that it can't be sorted or shows how to sort it by assigning p(i) to stack A or stack B for each i. The algorithm should run in time polynomial in n. How small can you make the exponent of n?

A PostScript version of this assignment (with better typesetting) is also available: download.

Last Modified: 3 Sep 1997 20:49:47 EDT by
Richard Chang

Back up to Fall 1997 CMSC 641 Homepage