Homework 1
Due Date: Sept. 4th (before class)
Assignment
-
R5.6 (Pg. 223)
Give a recursive function for removing all the elements in a stack.
-
C5.1 (Pg. 224)
Explain how you can implement all the functions of the deque ADT using two stacks.
-
C5.5 (Pg. 224)
Describe how to implement the stack ADT using two queues. What is the running time of the
push
andpop
functions in this case?
Bonus
C5.11 (Pg. 225)
Show how to use a stack S and a queue Q to generate all possible subsets of an n-element set T nonrecursively.
Grading Rubric
Each homework composes 2% of your final grade. Each homework will be graded out of 100 possible points. In any problem asking you to design an algorithm please also provide proper pseudocode (mathematical notation), complexity analysis (both space and time), and brief justification of complexity and correctness.
All assignments must be turned in with a signed coverpage. If no coverpage is provided, the assignment will not be graded.
If there are any discrepancies in grades please see Jory Denny during his office hours (not the TA or Grader).