Chapter 9: Graph Algorithms
9.1
The following ordering is arrived at by using a queue and assumes that vertices appear on an
adjacency list alphabetically. The topological order that results is then
s, G, D, H, A, B, E, I, F, C, t
9.2
Assuming the same ad

Data Structures
and
Algorithm Analysis in C
(second edition)
Solutions Manual
Mark Allen Weiss
Florida International University
Preface
Included in this manual are answers to most of the exercises in the textbook Data Structures and
Algorithm Analysis in

Chapter 5: Hashing
5.1
(a) On the assumption that we add collisions to the end of the list (which is the easier way if
a hash table is being built by hand), the separate chaining hash table that results is shown
here.
0
1
4371
2
3
1323
4
4344
6173
5
6
7
8

Chapter 8: The Disjoint Set ADT
8.1
We assume that unions operated on the roots of the trees containing the arguments. Also, in
case of ties, the second tree is made a child of the first. Arbitrary union and union by height
give the same answer (shown as

( )
(b) The information-theoretic lower bound is log 2N
N . Applying Stirlings formula, we
1
can estimate the bound as 2NO 2log NO. A better lower bound is known for this case:
2NO1 comparisons are necessary. Merging two lists of different sizes MO and NO

Chapter 6: Priority Queues (Heaps)
6.1
Yes. When an element is inserted, we compare it to the current minimum and change the
minimum if the new element is smaller. DeleteMinO operations are expensive in this
scheme.
6.2
1
1
3
2
6
15
6.3
7
14
12
3
5
9
10
4

Chapter 3: Lists, Stacks, and Queues
3.2
The comments for Exercise 3.4 regarding the amount of abstractness used apply here. The
running time of the procedure in Fig. 3.1 is O (L + P ).
_
O
O
O
void
PrintLots( List L, List P )
cfw_
int Counter;
Position L

Chapter 4: Trees
4.1
(a) A .
O
(b) G , H , I , L , M , and K .
O
4.2
O
O
O
O
O
For node B :
O
(a) A .
O
(b) D and E .
O
O
(c) C .
O
(d) 1.
(e) 3.
4.3
4.
4.4
There are N nodes. Each node has two pointers, so there are 2N pointers. Each node but
the root ha

Chapter 1: Introduction
1.3
Because of round-off errors, it is customary to specify the number of decimal places that
should be included in the output and round up accordingly. Otherwise, numbers come out
looking strange. We assume error checks have alrea

Chapter 10: Algorithm Design Techniques
10.1
First, we show that if NO evenly divides PO, then each of PjO(iO1)PO+1 through PjiPO must be
placed as the iOthO job on some processor. Suppose otherwise. Then in the supposed
optimal ordering, we must be able

Chapter 2: Algorithm Analysis
2.1
2/NO, 37, MM
NOO, NO, NOlog log NO, NOlog NO, NOlog (NO2), NOlog2NO, NO1.5, NO2, NO2log NO, NO3, 2NO/ 2,
NO
2 . NOlog NO and NOlog (NO2) grow at the same rate.
2.2
(a) True.
(b) False. A counterexample is TO1(NO) = 2NO, T