Publisher Greg Tobin
Senior Acquisitions Editor Michael Hirsch
Editorial Assistant Lindsey Triebel
Marketing Manager Michelle Brown
Marketing Assistant Dana Lopreato
Digital Asset Manager Marianne Groth
Composition Windfall Software, using ZzT
E
X
Proofreaders Melanie Aswell, Debbie Sidman
Access the latest information about Addison-Wesley titles from our World Wide Web site: http://www.aw-
bc.com/computing
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and Addison-Wesley was aware of a trademark
claim, the designations have been printed in initial caps or all caps.
Copyright © 2006 by Pearson Education, Inc.
For information on obtaining permission for use of material in this work, please submit a written request
to Pearson Education, Inc., Rights and Contract Department, 75 Arlington Street, Suite 300, Boston, MA
02116 or fax your request to (617) 848-7047.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or
transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or any other
media embodiments now known or hereafter to become known, without the prior written permission of
the publisher. Printed in the United States of America.
12345678910—PDF—08 07 06 05
CONTENTS
Preface v
Chapter 1 Introduction 1
Chapter 2 Algorithm Analysis 5
Chapter 3 Lists, Stacks, and Queues 9
Chapter 4 Trees 29
Chapter 5 Hashing 41
Chapter 6 Priority Queues (Heaps) 45
Chapter 7 Sor ting 53
Chapter 8 The Disjoint Set 59
Chapter 9 Graph Algorithms 63
Chapter 10 Algorithm Design Techniques 77
Chapter 11 Amortized Analysis 87
Chapter 12 Advanced Data Structures and Implementation 91
iii
PREFACE
Included in this manual are answers to many of the exercises in the textbook Data Structures and
Algorithm Analysis in C++, third edition, published by Addison-Wesley. These answers reflect the
state of the book in the first printing of the third edition.
Specifically omitted are general programming questions and any question whose solution is
pointed to by a reference at the end of the chapter. Solutions vary in degree of completeness; generally,
minor details are left to the reader. For clarity, the few code segments that are present are meant to
be pseudo-C++ rather than completely perfect code.
Errors can be reported to weiss@fiu.edu.
v