CPSC 221H-200: Data Structures & Algorithms
Homework Assignment #1
Spring 2009


General Guidelines for Homework


Assigned Problems

Due: Thursday January 29, 2009 at the beginning of class

  1. Problem R-4.8 in the text (p. 196). (20 points)

  2. Problem R-4.10 in the text (p. 196). (20 points)

  3. Problem C-4.9 in the text (p. 199). (30 points)

  4. Design a version of the size() operation of a stack that used only pop(), push(obj), and isEmpty() operations, and does not use any internal variable of the underlying array (i.e., you cannot use the implementation of size() in the text). Express your algorithm using pseudo-code, including comments to explain the various steps.

    What is the running time of your size() operation assuming there are N elements in the stack when size() is invoked. Express your answer using asymptotic notion. Compare the efficiency of this new version of size() with the version in the text that uses the internal variable t. Which one is more efficient? You MUST explain your reasoning to obtain full credit. (30 points)


Bonus Problems

Due by Thursday February 12, 2008

These problems can be done for extra credit. Points for bonus problems will be tabulated separately, and will be considered separately at the end of the semester. They should be turned in separately from your regular assignment. They will be accepted upto two weeks past the due date of the assignment.