文档介绍:Page iii
Mastering Algorithms with Perl
Jon Orwant, Jarkko Hietaniemi,
and John Macdonald
Page iv
Mastering Algorithms with Perl
by Jon Orwant, Jarkko Hietaniemi. and John Macdonald
Copyright © 1999 O'Reilly & Associates, Inc. All rights reserved.
Printed in the United States of America.
Cover illustration by Lorrie LeJeune, Copyright © 1999 O'Reilly & Associates, Inc.
Published by O'Reilly & Associates, Inc., 101 Morris Street, Sebastopol, CA 95472.
Editors: Andy Oram and Jon Orwant
Production Editor: Melanie Wang
Printing History:
August 1999: First Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered
trademarks of O'Reilly & Associates, Inc. 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 O'Reilly & Associates, Inc. was aware of a trademark claim, the
designations have been printed in caps or initial caps. The association between the image of a
wolf and the topic of Perl algorithms is a trademark of O'Reilly & Associates, Inc.
While every precaution has been taken in the preparation of this book, the publisher assumes no
responsibility for errors or omissions, or for damages resulting from the use of the information
contained herein.
ISBN: 1-56592-398-7 [1/00]
[M]]break
Page v
Table of Contents
Preface xi
1. Introduction 1
What Is an Algorithm? 1
Efficiency 8
Recurrent Themes in Algorithms 20
2. Basic Data Structures 24
Perl's Built-in Data Structures 25
Build Your Own Data Structure 26
A Simple Example 27
Perl Arrays: Many Data Structures in One 37
3. Advanced Data Structures 46
Linked Lists 47
Circular Linked Lists 60
Garbage Collection in Perl 62
Doubly-Linked Lists 65
Doubly-Linked Lists 65
Infinite Lists 71
The Cost of Traversal 72
Binary Trees 73
Heaps 91
Binary Heaps 92
Janus Heap 99
Page vi
The Heaps Module 99
Future CPAN Mo