Solutions Manual
Data
Structures
and Algorithm
Analysis in
Co+
Third Edition
Mark Allen Weiss
Florida International University
boston San Francico New York
London Toronto Sydney Tokyo Singapore Madrid
Mexico City Munich Paris Cape Town Hong Kong Montreal
about:blank 1/97
,6/27/23, 2:15 PM Data Structures and Algorithm Analysis in C++ Solution Manual,3rd Editio…
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 ZzTEX
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.
1 2 3 4 5 6 7 8 9 10—PDF—08 07 06 05
about:blank 2/97
,6/27/23, 2:15 PM Data Structures and Algorithm Analysis in C++ Solution Manual,3rd Editio…
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 Sorting 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
about:blank 3/97
, 6/27/23, 2:15 PM Data Structures and Algorithm Analysis in C++ Solution Manual,3rd Editio…
Included nin nthis nmanual nare nanswers nto nmany nof nthe nexercises nin nthe ntextbook nData nStructures
nand n Algorithm nAnalysis nin nC++, nthird nedition, npublished nby nAddison-Wesley. nThese nanswers
nreflect nthe n state nof nthe n book nin nthe n first nprinting nof nthe nthird nedition.
Specifically nomitted nare ngeneral nprogramming nquestions nand nany nquestion nwhose nsolution
nis n pointed nto nby na nreference nat nthe nend nof nthe nchapter. nSolutions n vary n in ndegree nof ncompleteness;
n generally, n minor ndetails nare nleft nto nthe nreader. nFor nclarity, nthe nfew ncode nsegments nthat nare
npresent nare nmeant nto n be npseudo-C++ nrather nthan ncompletely nperfect ncode.
Errors ncan nbe nreported nto .
v
about:blank 4/97