没有合适的资源?快使用搜索试试~ 我知道了~
首页Python Algorithms
资源详情
资源评论
资源推荐

this print for content only—size & color not accurate 7.5 x 9.25 spine = 0.5" 336 page count 692 ppi
Hetland
Python Algorithms
THE EXPERT’S VOICE
®
IN OPEN SOURCE
Python
Algorithms
Mastering Basic Algorithms in the
Python Language
CYAN
MAGENTA
YELLOW
BLACK
PANTONE 123 C
Magnus Lie Hetland
Companion
eBook
Available
Learn to implement classic algorithms and design
new problem-solving algorithms using Python
BOOKS FOR PROFESSIONALS BY PROFESSIONALS
®
Magnus Lie Hetland,
Author of
Beginning Python: From
Novice to Professional,
Second Edition
Shelve in:
Programming / Python
User level:
Intermediate – Advanced
THE APRESS ROADMAP
Pro
Python
Python
Algorithms
Beginning
Python Visualization
Beginning Python,
Second Edition
THE APRESS ROADMAP
Pro
Python
Python
Algorithms
Beginning
Python Visualization
Beginning Python,
Second Edition
www.apress.com
SOURCE CODE ONLINE
Companion eBook
See last page for details
on $10 eBook version
ISBN 978-1-4302-3237-7
9 781430 232377
54999
Python Algorithms: Mastering Basic
Algorithms in the Python Language
Dear Reader,
Python Algorithms explains the Python approach to algorithm analysis and
design. Written by Magnus Lie Hetland, author of Beginning Python, this book
is sharply focused on classical algorithms, but also gives a solid understanding
of fundamental algorithmic problem-solving techniques.
Python Algorithms deals with some of the most important and challenging
areas of programming and computer science in a highly pedagogic and read-
able manner. It covers both algorithmic theory and programming practice,
demonstrating how theory is reflected in real Python programs.
Python Algorithms explains well-known algorithms and data structures built
into the Python language, and shows you how to implement and evaluate others.
You’ll learn how to:
•Transformnewproblemstowell-knownalgorithmicproblemswithefficient
solutions, or formally show that a solution is unfeasible.
•AnalyzealgorithmsandPythonprogramsbothusingmathematicaltoolsand
basic experiments and benchmarks.
•Provecorrectness,optimality,orboundsonapproximationerrorforPython
programs and their underlying algorithms.
•Understandseveralclassicalalgorithmsanddatastructuresindepth,andlearn
to implement these efficiently in Python.
•Designandimplementnewalgorithmsfornewproblems,usingtime-tested
design principles and techniques.
Whether you’re a Python programmer who needs to learn about algorithmic prob-
lem-solving, or a student of Computer Science, this book will help you to under-
stand and implement classic algorithms, and it will help you create new ones.

Python Algorithms
Mastering Basic Algorithms in the
Python Language
■ ■ ■
Magnus Lie Hetland

Python Algorithms: Mastering Basic Algorithms in the Python Language
Copyright © 2010 by Magnus Lie Hetland
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any
means, electronic or mechanical, including photocopying, recording, or by any information
storage or retrieval system, without the prior written permission of the copyright owner and
the publisher.
ISBN-13 (pbk): 978-1-4302-3237-7
ISBN-13 (electronic): 978-1-4302-3238-4
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names, logos, and images may appear in this book. Rather than use a trademark
symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and
images only in an editorial fashion and to the benefit of the trademark owner, with no intention of
infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if
they are not identified as such, is not to be taken as an expression of opinion as to whether or not
they are subject to proprietary rights.
President and Publisher: Paul Manning
Lead Editor: Frank Pohlmann
Development Editor: Douglas Pundick
Technical Reviewer: Alex Martelli
Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell,
Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie,
Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick,
Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh
Coordinating Editor: Adam Heath
Compositor: Mary Sudul
Indexer: Brenda Miller
Artist: April Milne
Cover Designer: Anna Ishchenko
Photo Credit: Kai T. Dragland
Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring
Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail
orders-
ny@springer-sbm.com, or visit www.springeronline.com.
For information on translations, please e-mail
rights@apress.com, or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional
use. eBook versions and licenses are also available for most titles. For more information, reference
our Special Bulk Sales–eBook Licensing web page at
www.apress.com/info/bulksales.
The information in this book is distributed on an “as is” basis, without warranty. Although every
precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall
have any liability to any person or entity with respect to any loss or damage caused or alleged to be
caused directly or indirectly by the information contained in this work.
The source code for this book is available to readers at
www.apress.com

■ CONTENTS
v
Contents at a Glance
Contents...................................................................................................................vi
About the Author ...................................................................................................xiii
About the Technical Reviewer ............................................................................... xiv
Acknowledgments .................................................................................................. xv
Preface .................................................................................................................. xvi
■ Chapter 1: Introduction........................................................................................1
■ Chapter 2: The Basics ..........................................................................................9
■ Chapter 3: Counting 101 ....................................................................................45
■ Chapter 4: Induction and Recursion … and Reduction......................................71
■ Chapter 5: Traversal: The Skeleton Key of Algorithmics .................................101
■ Chapter 6: Divide, Combine, and Conquer........................................................125
■ Chapter 7: Greed Is Good? Prove It!.................................................................151
■ Chapter 8: Tangled Dependencies and Memoization .......................................175
■ Chapter 9: From A to B with Edsger and Friends.............................................199
■ Chapter 10: Matchings, Cuts, and Flows .........................................................221
■ Chapter 11: Hard Problems and (Limited) Sloppiness .....................................241
■ Appendix A: Pedal to the Metal: Accelerating Python .....................................271
■ Appendix B: List of Problems and Algorithms .................................................275
■ Appendix C: Graph Terminology.......................................................................285
■ Appendix D: Hints for Exercises.......................................................................291
■ Index ................................................................................................................307

■ CONTENTS
vi
Contents
Contents at a Glance.................................................................................................v
About the Author ...................................................................................................xiii
About the Technical Reviewer ............................................................................... xiv
Acknowledgments .................................................................................................. xv
Preface .................................................................................................................. xvi
■ Chapter 1: Introduction........................................................................................1
What’s All This, Then? .....................................................................................................2
Why Are You Here? ..........................................................................................................3
Some Prerequisites .........................................................................................................4
What’s in This Book .........................................................................................................5
Summary .........................................................................................................................6
If You’re Curious … .........................................................................................................6
Exercises .........................................................................................................................7
References.......................................................................................................................7
■ Chapter 2: The Basics ..........................................................................................9
Some Core Ideas in Computing .......................................................................................9
Asymptotic Notation ......................................................................................................10
It’s Greek to Me! ...................................................................................................................................12
Rules of the Road .................................................................................................................................14
Taking the Asymptotics for a Spin........................................................................................................16
Three Important Cases .........................................................................................................................19
Empirical Evaluation of Algorithms.......................................................................................................20
剩余323页未读,继续阅读















安全验证
文档复制为VIP权益,开通VIP直接复制

评论1