Answers to Homework 3
CPS 400/2
Problem 1. (12 points) Mehlhorn & Sanders Ex. 3.9.
A N ANSWER : To make the math a bit simpler, pick m = 3 2k for some k > 0. Note
that with = 2, the size of the array b is always a power of 2. Here is the sequence.
(a) Do

Answers to Homework 4 Part II
Problem 1. (10 points) Mehlhorn and Sanders, Exercise 6.3
A N ANSWER : In array order: 4 3 2 1, 4 2 3 1, and 4 3 1 2.
Or as trees:
4
3
1
4
2
2
1
4
3
3
1
2
Problem 2. (10 points) Show how to implement a stack (See section 3.4

Answers for Homework 6
CIS 675 O Algorithms
Answer to Problem 1. Tree edges: solid, back edges, dotted
a
1
d
12
13
b
2
h
11
15
c
3
18
16
e
10
5
g
6
14
17
f
4
9
November 17, 2013
Analysis: The outer for-loop executes once per vertex; and for each value of

Answers for Homework 8
CIS 675 O Algorithms
Answer to Problem 1. Suppose the expression dag has a label, which is either
a number (in which case the vertex has outdegree 0) or else an operation (in
which case the vertex has outdegree 2). We keep an array

Answers for Quiz 2
CPS 400/2: Data Structures & Algorithms
Problem 1 (4 points) Consider the following ten numbers:
An answer.
(a) The rst for-loop inserts each element x of a into H with key value x. Thus
in the i-th step of the second for-loop (i = 0, .

Practice Questions for Quiz 4, Version 2
Topics
CPS 400/2 ! Data Structures & Algorithms
(ii) s, t V ,
(iii) E V V is a set of edges with E E = , and
(iv) each edge e ( E E ) is assigned length e > 0.
Graph representations Applications of Breadth-rst and