Programming Books C Java PHP Python Learn more Browse Programming Books
Buy New
$32.65
Qty:1
  • List Price: $44.99
  • Save: $12.34 (27%)
FREE Shipping on orders over $35.
In Stock.
Ships from and sold by Amazon.com.
Gift-wrap available.
Programming Pearls (2nd E... has been added to your Cart
Trade in your item
Get a $9.90
Gift Card.
Have one to sell? Sell on Amazon
Flip to back Flip to front
Listen Playing... Paused   You're listening to a sample of the Audible audio edition.
Learn more
See all 2 images

Programming Pearls (2nd Edition) Paperback – October 7, 1999

ISBN-13: 078-5342657883 ISBN-10: 0201657880 Edition: 2nd

Buy New
Price: $32.65
50 New from $25.62 29 Used from $25.61
Amazon Price New from Used from
Paperback
"Please retry"
$32.65
$25.62 $25.61
Unknown Binding
"Please retry"
Free%20Two-Day%20Shipping%20for%20College%20Students%20with%20Amazon%20Student

$32.65 FREE Shipping on orders over $35. In Stock. Ships from and sold by Amazon.com. Gift-wrap available.

Frequently Bought Together

Programming Pearls (2nd Edition) + Programming Interviews Exposed: Secrets to Landing Your Next Job + Cracking the Coding Interview: 150 Programming Questions and Solutions
Price for all three: $78.54

Buy the selected items together

NO_CONTENT_IN_FEATURE

Shop the new tech.book(store)
New! Introducing the tech.book(store), a hub for Software Developers and Architects, Networking Administrators, TPMs, and other technology professionals to find highly-rated and highly-relevant career resources. Shop books on programming and big data, or read this week's blog posts by authors and thought-leaders in the tech industry. > Shop now

Product Details

  • Paperback: 256 pages
  • Publisher: Addison-Wesley Professional; 2 edition (October 7, 1999)
  • Language: English
  • ISBN-10: 0201657880
  • ISBN-13: 978-0201657883
  • Product Dimensions: 9.2 x 6.3 x 0.7 inches
  • Shipping Weight: 12.8 ounces (View shipping rates and policies)
  • Average Customer Review: 4.3 out of 5 stars  See all reviews (64 customer reviews)
  • Amazon Best Sellers Rank: #15,124 in Books (See Top 100 in Books)

Editorial Reviews

Amazon.com Review

Fourteen years after it was first issued, C++ expert Jon Bentley reinvents a true classic with the second edition of his Programming Pearls. Completely revised and brought up to date with all new code examples in C and C++, this book remains an exceptional tutorial for learning to think like a programmer.

The "pearls" in question center not only on choosing the right algorithms (like binary searches, sorting techniques, or sparse arrays) but also on showing how to solve problems effectively. Each chapter frames a particular programming task--such as sorting numbers, creating anagrams, or counting the words in a block of text--many drawn from Bentley's experiences in his long career as a developer. The book traces the process of arriving at a fast, efficient, and accurate solution, along with code profiling to discover what works best. After refining the correct answer, each chapter enumerates programming principles that you can use on your own.

The author also challenges you to think like an engineer, and each chapter ends with about a dozen problems to get you thinking creatively about design issues. (Sidebars on such historical topics as the first computer solutions to computer chess, spell-checking, and even architectural design help create a perspective on successful problem solving and make for a truly educational and enjoyable tour of how to become a better programmer.) Bentley also asks the reader to think analytically about the world with "back of the envelope" estimation techniques drawn from engineering. Appendices list the algorithms and code rules covered in the book, plus some sample solutions.

Fans of the first edition of this title will be pleased to see this favorite computer text brought up to date for today's faster hardware. Whether you want to improve your command of algorithms or test your problem-solving skills, the new version of Programming Pearl is a challenging, instructive, and thoroughly entertaining resource. --Richard Dragan

Topics covered: Programming and problem-solving tutorial, sorting algorithms, merge sort, bit vectors, binary searches, program correctness and testing, improving performance, engineering and problem-solving techniques, performance estimates, designing for safety, divide-and-conquer and scanning algorithms, tuning code, tips for more efficient memory usage, insertion sort, quicksort algorithms, sparse arrays, searching algorithms, binary search trees, heaps, priority queues, searching text, and generating random text.

From the Inside Flap

Computer programming has many faces. Fred Brooks paints the big picture in

The Mythical Man Month; his essays underscore the crucial role of management

in large software projects. At a finer grain, Steve McConnell teaches good programming

style in Code Complete. The topics in those books are the key to good software

and the hallmark of the professional programmer. Unfortunately, though, the

workmanlike application of those sound engineering principles isn't always thrilling

-- until the software is completed on time and works without surprise.

About the Book
The columns in this book are about a more glamorous aspect of the profession:

programming pearls whose origins lie beyond solid engineering, in the realm

of insight and creativity. Just as natural pearls grow from grains of sand that

have irritated oysters, these programming pearls have grown from real problems

that have irritated real programmers. The programs are fun, and they teach important

programming techniques and fundamental design principles.

Most of these essays originally appeared in my ''Programming Pearls'' column

in Communications of the Association for Computing Machinery. They were

collected, revised and published as the first edition of this book in 1986.

Twelve of the thirteen pieces in the first edition have been edited substantially

for this edition, and three new columns have been added.

The only background the book assumes is programming experience in a high-level

language. Advanced techniques (such as templates in C++) show up now and then,

but the reader unfamiliar with such topics will be able to skip to the next

section with impunity.

Although each column may be read by itself, there is a logical grouping to

the complete set. Columns 1 through 5 form Part I of the book. They review programming

fundamentals: problem definition, algorithms, data structures and program verification

and testing. Part II is built around the theme of efficiency, which is sometimes

important in itself and is always a fine springboard into interesting programming

problems. Part III applies those techniques to several substantial problems

in sorting, searching and strings.

One hint about reading the essays: don't go too fast. Read them carefully,

one per sitting. Try the problems as they are posed -- some of them look easy

until you've butted your head against them for an hour or two. Afterwards, work

hard on the problems at the end of each column: most of what you learn from

this book will come out the end of your pencil as you scribble down your solutions.

If possible, discuss your ideas with friends and colleagues before peeking at

the hints and solutions in the back of the book. The further reading at the

end of each chapter isn't intended as a scholarly reference list; I've recommended

some good books that are an important part of my personal library.

This book is written for programmers. I hope that the problems, hints, solutions,

and further reading make it useful for individuals. The book has been used in

classes including Algorithms, Program Verification and Software Engineering.

The catalog of algorithms in Appendix 1 is a reference for practicing programmers,

and also shows how the book can be integrated into classes on algorithms and

data structures.

The Code
The pseudocode programs in the first edition of the book were all implemented,

but I was the only person to see the real code. For this edition, I have rewritten

all the old programs and written about the same amount of new code. The programs

are available at this book's web site. The code includes much of the scaffolding

for testing, debugging and timing the functions. The site also contains other

relevant material. Because so much software is now available online, a new theme

in this edition is how to evaluate and use software components.

The programs use a terse coding style: short variable names, few blank lines,

and little or no error checking. This is inappropriate in large software projects,

but it is useful to convey the key ideas of algorithms. Solution 5.1 gives more

background on this style. The text includes a few real C and C++ programs, but

most functions are expressed in a pseudocode that takes less space and avoids

inelegant syntax. The notation for i = 0, n) iterates i from

0 through n-1. In these for loops, left and right parentheses denote

open ranges (which do not include the end values), and left and right square

brackets denote closed ranges (which do include the end values). The phrase

function(i, j) still calls a function with parameters i and j,

and arrayi, j still accesses an array element.

This edition reports the run times of many programs on ''my computer'', a 400MHz

Pentium II with 128 megabytes of RAM running Windows NT 4.0. I timed the programs

on several other machines, and the book reports the few substantial differences

that I observed. All experiments used the highest available level of compiler

optimization. I encourage you to time the programs on your machine; I bet that

you'll find similar ratios of run times.

To Readers of the First Edition
I hope that your first response as you thumb through this edition of the book

is, ''This sure looks familiar.'' A few minutes later, I hope that you'll observe,

''I've never seen that before.''

This version has the same focus as the first edition, but is set in a larger

context. Computing has grown substantially in important areas such as databases,

networking and user interfaces. Most programmers should be familiar users of

such technologies. At the center of each of those areas, though, is a hard core

of programming problems. Those programs remain the theme of this book. This

edition of the book is a slightly larger fish in a much larger pond.

One section from old Column 4 on implementing binary search grew into new Column

5 on testing, debugging and timing. Old Column 11 grew and split into new Columns

12 (on the original problem) and 13 (on set representations). Old Column 13

described a spelling checker that ran in a 64-kilobyte address space; it has

been deleted, but its heart lives on in Section 13.8. New Column 15 is about

string problems. Many sections have been inserted into the old columns, and

other sections were deleted along the way. With new problems, new solutions,

and four new appendices, this edition of the book is 25 percent longer.

Many of the old case studies in this edition are unchanged, for their historical

interest. A few old stories have been recast in modern terms.

Acknowledgments for the First Edition
I am grateful for much support from many people. The idea for a Communications

of the ACM column was originally conceived by Peter Denning and Stuart Lynn.

Peter worked diligently within ACM to make the column possible and recruited

me for the job. ACM Headquarters staff, particularly Roz Steier and Nancy Adriance,

have been very supportive as these columns were published in their original

form. I am especially indebted to the ACM for encouraging publication of the

columns in their present form, and to the many CACM readers who made

this expanded version necessary and possible by their comments on the original

columns.

Al Aho, Peter Denning, Mike Garey, David Johnson, Brian Kernighan, John Linderman,

Doug McIlroy and Don Stanat have all read each column with great care, often

under extreme time pressure. I am also grateful for the particularly helpful

comments of Henry Baird, Bill Cleveland, David Gries, Eric Grosse, Lynn Jelinski,

Steve Johnson, Bob Melville, Bob Martin, Arno Penzias, Marilyn Roper, Chris

Van Wyk, Vic Vyssotsky and Pamela Zave. Al Aho, Andrew Hume, Brian Kernighan,

Ravi Sethi, Laura Skinger and Bjarne Stroustrup provided invaluable help in

bookmaking, and West Point cadets in EF 485 field tested the penultimate draft

of the manuscript. Thanks, all.

Acknowledgments for the Second Edition
Dan Bentley, Russ Cox, Brian Kernighan, Mark Kernighan, John Linderman, Steve

McConnell, Doug McIlroy, Rob Pike, Howard Trickey and Chris Van Wyk have all

read this edition with great care. I am also grateful for the particularly helpful

comments of Paul Abrahams, Glenda Childress, Eric Grosse, Ann Martin, Peter

McIlroy, Peter Memishian, Sundar Narasimhan, Lisa Ricker, Dennis Ritchie, Ravi

Sethi, Carol Smith, Tom Szymanski and Kentaro Toyama. I thank Peter Gordon and

his colleagues at Addison-Wesley for their help in preparing this edition.

0201657880P04062001


More About the Author

Discover books, learn about writers, read author blogs, and more.

Customer Reviews

I recommend it to those who want to do serious programming.
W. Wen
Great way to prepare programming interview questions, whether you're an interviewer or interviewee.
Atul Shenoy
This is one of my favorite programming books, as I always find something 'new' just by browsing it.
Manuel A. Ricart

Most Helpful Customer Reviews

86 of 89 people found the following review helpful By Mike Christie on June 17, 2000
Format: Paperback
The thirteen columns in this book appeared in the Communications of the ACM between 1983 and 1985. There can't be more than a couple of technical books on computing from that era that are still worth reading. Kernighan & Ritchie's book, "The C Programming Language", is one that springs to mind; this book is definitely another, and will probably outlast K&R as it has almost no ties to existing or past hardware or languages.
What Bentley does in each of these columns is take some part of the field of programming--something that every one of us will have run into at some point in our work--and dig underneath it to reveal the part of the problem that is permanent; that doesn't change from language to language. The first two parts cover problem definition, algorithms, data structures, program verification, and efficiency (performance, code tuning, space tuning); the third part applies the lessons to example pseudocode, looking at sorting, searching, heaps, and an example spellchecker.
Bentley writes clearly and enthusiastically, and the columns are a pleasure to read. But the reason so many people love this book is not for the style, it's for the substance--you can't read this book and not come away a better programmer. Inefficiency, clumsiness, inelegance and obscurity will offend you just a little more after you've read it.
It's hard to pick a favourite piece, but here's one nice example from the algorithm design column that shows how little the speed of your Pentium matters if you don't know what you're doing. Bentley presents a particular problem (the details don't matter) and multiple different ways to solve it, calculating the relationship between problem size and run time for each algorithm.
Read more ›
Comment Was this review helpful to you? Yes No Sending feedback...
Thank you for your feedback. If this review is inappropriate, please let us know.
Sorry, we failed to record your vote. Please try again
86 of 93 people found the following review helpful By Charles Ashbacher HALL OF FAMETOP 500 REVIEWERVINE VOICE on March 2, 2000
Format: Paperback
Without any doubt, my favorite article in _Communications of the ACM_ in the 1980's was the regular `Programming Pearls' articles by Jon Bentley. When the first edition of these collected gems was published, I read it with great delight. Now, over a decade later, a second edition has been published, containing the same problems with additional modifications and notations. Given the enormous changes in programming since the mid 80's, your first reaction might be that this book is dated and therefore irrelevant. Nothing could be further from the truth.
Elegant solutions to complex programming problems are free from the rot of time. Programming is a thought process largely independent of the notation used to write it down. The solutions are sketched and explained rather than coded, and the solutions are complete. There is a certain mystique about taking a complex problem, finding an initial solution and then refining it down until it kicks some big time. There are some major lessons in program refinement explained in these solutions.
Coding a binary search is covered quite extensively, which may seem like a waste of space, as this problem was solved decades ago. However, that solution took decades to get right, and this is one of those "separates the coders from the key bangers" type of problem. Other problems examined include performance tuning, squeezing space and program correctness. While the improvement in the performance of the hardware has been astounding since these solutions were written, that does not make them obsolete. The complexity of the programs that we now build has risen even faster, so performance and space considerations are just as critical.
Some problems were here at the beginning and will still be here at the end.
Read more ›
1 Comment Was this review helpful to you? Yes No Sending feedback...
Thank you for your feedback. If this review is inappropriate, please let us know.
Sorry, we failed to record your vote. Please try again
20 of 22 people found the following review helpful By Russell Belfer on December 18, 1999
Format: Paperback
It's great to see they've come out with an update to this book. The essays in this book are easy to read and touch on many valuable things, such as tuning and optimization of algorithms, using mini languages to provide robust tools, doing back-of-the-envelope calculations, and much more. I have recommended this book to several beginning programmers that I know as an excellent introduction to thinking effectively about the challenges of software engineering.
Comment Was this review helpful to you? Yes No Sending feedback...
Thank you for your feedback. If this review is inappropriate, please let us know.
Sorry, we failed to record your vote. Please try again
12 of 13 people found the following review helpful By a reader on August 19, 2004
Format: Paperback Verified Purchase
Programming pearls is a compendium of 15 columns previously published in Communications of the ACM. The columns cover a wide range of topics related to programming: from requirements gathering to performance tuning. The focus is primarily on coding techniques and algorithms.

Each column has been reorganized as a chapter. Chapters usually start with the presentation of a practical problem. Then various solutions are presented and are used as lessons to be learned. The writing style is clear and fun.

Programming Pearls is not a usual book teaching new programming concepts. Although it contains good and sometimes quite novel ideas, the aim of the book is not to teach something new. For example, the search and sort algorithms presented are well-known. The aim is to remind programmers to think hard before starting writing code. The book has great chapter on back-of-the-envelope computation for example which is useful when comparing various solutions. The easy solutions to the column's problems are usually very slow. The `good' solutions are lightening fast but require thinking hard about the problems. I would recommend having a book about algorithms nearby when reading Programming Pearls.

The book is full of little (and some not so little) exercises that are given throughout the chapters. Solutions or hints are given at the end. The exercises usually take a few hours to do properly and are a great resource. Again the emphasis is on making the reader think.

If you consider programming a repetitious activity, Programming Pearls will provoke you into thinking harder about finding elegant solutions. I recommend this book.
Comment Was this review helpful to you? Yes No Sending feedback...
Thank you for your feedback. If this review is inappropriate, please let us know.
Sorry, we failed to record your vote. Please try again

Most Recent Customer Reviews


What Other Items Do Customers Buy After Viewing This Item?