100% found this document useful (1 vote)
31 views

Data Structures & Algorithms in Python John Canning - Download the ebook now and own the full detailed content

The document provides information about various eBooks available for download, particularly focusing on 'Data Structures & Algorithms in Python' by John Canning. It includes links to additional recommended titles and outlines the contents of the main book, which covers a wide range of data structures and algorithms. The document also emphasizes Pearson's commitment to diversity and inclusion in educational content.

Uploaded by

raudinrabadi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
31 views

Data Structures & Algorithms in Python John Canning - Download the ebook now and own the full detailed content

The document provides information about various eBooks available for download, particularly focusing on 'Data Structures & Algorithms in Python' by John Canning. It includes links to additional recommended titles and outlines the contents of the main book, which covers a wide range of data structures and algorithms. The document also emphasizes Pearson's commitment to diversity and inclusion in educational content.

Uploaded by

raudinrabadi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 74

Read Anytime Anywhere Easy Ebook Downloads at ebookmeta.

com

Data Structures & Algorithms in Python John


Canning

https://ebookmeta.com/product/data-structures-algorithms-in-
python-john-canning/

OR CLICK HERE

DOWLOAD EBOOK

Visit and Get More Ebook Downloads Instantly at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Data Structures and Algorithms with Python: With an


Introduction to Multiprocessing (Undergraduate Topics in
Computer Science) Lee
https://ebookmeta.com/product/data-structures-and-algorithms-with-
python-with-an-introduction-to-multiprocessing-undergraduate-topics-
in-computer-science-lee/
ebookmeta.com

Data Structures & Algorithms using Kotlin, Second Edition


Hemant Jain

https://ebookmeta.com/product/data-structures-algorithms-using-kotlin-
second-edition-hemant-jain/

ebookmeta.com

Problem Solving in Data Structures Algorithms Using C 2nd


Edition Hemant Jain

https://ebookmeta.com/product/problem-solving-in-data-structures-
algorithms-using-c-2nd-edition-hemant-jain/

ebookmeta.com

Insight Guides Scandinavia 5th Edition Insight Guides

https://ebookmeta.com/product/insight-guides-scandinavia-5th-edition-
insight-guides/

ebookmeta.com
International Relations Theory 1st Edition Mykola
Kapitonenko

https://ebookmeta.com/product/international-relations-theory-1st-
edition-mykola-kapitonenko/

ebookmeta.com

Tiresian name Inbida T siendiel 01 overview 2400 dpi First


Edition Studio Ammonite

https://ebookmeta.com/product/tiresian-name-inbida-t-
siendiel-01-overview-2400-dpi-first-edition-studio-ammonite/

ebookmeta.com

Analysis of Composite Laminates: Theories and Their


Applications 1st Edition Dinghe Li

https://ebookmeta.com/product/analysis-of-composite-laminates-
theories-and-their-applications-1st-edition-dinghe-li/

ebookmeta.com

Captured by the Magi 1st Edition Jl Madore Ruby Night

https://ebookmeta.com/product/captured-by-the-magi-1st-edition-jl-
madore-ruby-night/

ebookmeta.com

This Pact is Not Ours 1st Edition Zachary Sergi

https://ebookmeta.com/product/this-pact-is-not-ours-1st-edition-
zachary-sergi/

ebookmeta.com
Singing for Dummies 3rd Edition Pamelia S. Phillips

https://ebookmeta.com/product/singing-for-dummies-3rd-edition-pamelia-
s-phillips/

ebookmeta.com
Data Structures & Algorithms in Python
Data Structures & Algorithms in
Python

John Canning
Alan Broder
Robert Lafore

Boston • Columbus • New York • San Francisco • Amsterdam • Cape Town


Dubai • London • Madrid • Milan • Munich • Paris • Montreal • Toronto • Delhi • Mexico City
São Paulo • Sidney • Hong Kong • Seoul • Singapore • Taipei • Tokyo
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 the publisher was aware of a
trademark claim, the designations have been printed with initial capital letters or in all capitals.
The authors and publisher have taken care in the preparation of this book, but make no expressed or
implied warranty of any kind and assume no responsibility for errors or omissions. No liability is
assumed for incidental or consequential damages in connection with or arising out of the use of the
information or programs contained herein.
For information about buying this title in bulk quantities, or for special sales opportunities (which
may include electronic versions; custom cover designs; and content particular to your business,
training goals, marketing focus, or branding interests), please contact our corporate sales department
at corpsales@pearsoned.com or (800) 382-3419.
For government sales inquiries, please contact governmentsales@pearsoned.com.
For questions about sales outside the U.S., please contact intlcs@pearson.com.
Visit us on the Web: informit.com/aw
Library of Congress Control Number: 2022910068
Copyright © 2023 Pearson Education, Inc.
All rights reserved. Printed in the United States of America. This publication is protected by
copyright, and permission must be obtained from the publisher prior to any prohibited reproduction,
storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical,
photocopying, recording, or likewise. For information regarding permissions, request forms and the
appropriate contacts within the Pearson Education Global Rights & Permissions Department, please
visit www.pearsoned.com/permissions/.
ISBN-13: 978-0-13-485568-4
ISBN-10: 0-13-485568-X
ScoutAutomatedPrintCode
Editor-in-Chief
Mark Taub
Director, ITP Product Management
Brett Bartow
Acquisitions Editor
Kim Spenceley
Development Editor
Chris Zahn
Managing Editor
Sandra Schroeder
Project Editor
Mandie Frank
Copy Editor
Chuck Hutchinson
Indexer
Proofreader
Editorial Assistant
Cindy Teeters
Designer
Chuti Prasertsith
Compositor
codeMantra
Pearson’s Commitment to
Diversity, Equity, and Inclusion
Pearson is dedicated to creating bias-free content that reflects the diversity
of all learners. We embrace the many dimensions of diversity, including but
not limited to race, ethnicity, gender, socioeconomic status, ability, age,
sexual orientation, and religious or political beliefs.
Education is a powerful force for equity and change in our world. It has the
potential to deliver opportunities that improve lives and enable economic
mobility. As we work with authors to create content for every product and
service, we acknowledge our responsibility to demonstrate inclusivity and
incorporate diverse scholarship so that everyone can achieve their potential
through learning. As the world’s leading learning company, we have a duty
to help drive change and live up to our purpose to help more people create a
better life for themselves and to create a better world.
Our ambition is to purposefully contribute to a world where
• Everyone has an equitable and lifelong opportunity to succeed
through learning
• Our educational products and services are inclusive and represent the
rich diversity of learners
• Our educational content accurately reflects the histories and
experiences of the learners we serve
• Our educational content prompts deeper discussions with learners and
motivates them to expand their own learning (and worldview)
While we work hard to present unbiased content, we want to hear from you
about any concerns or needs with this Pearson product so that we can
investigate and address them.
Please contact us with concerns about any potential bias at
https://www.pearson.com/report-bias.html.
To my mother, who gave me a thirst for knowledge, to my father, who
taught me the joys of engineering, and to June, who made it possible to
pursue both.

John Canning

For my father Sol Broder, a computer science pioneer, who inspired me to


follow in his footsteps.

To my mother Marilyn Broder, for showing me the satisfaction of teaching


others.

To Fran, for making my life complete.

Alan Broder
Contents
1. Overview

2. Arrays

3. Simple Sorting

4. Stacks and Queues

5. Linked Lists

6. Recursion

7. Advanced Sorting

8. Binary Trees

9. 2-3-4 Trees and External Storage

10. AVL and Red-Black Trees

11. Hash Tables

12. Spatial Data Structures

13. Heaps

14. Graphs

15. Weighted Graphs

16. What to Use and Why


Appendix A. Running the Visualizations

Appendix B. Further Reading

Appendix C. Answers to Questions


Table of Contents
1. Overview
What Are Data Structures and Algorithms?
Overview of Data Structures
Overview of Algorithms
Some Definitions
Programming in Python
Object-Oriented Programming
Summary
Questions
Experiments

2. Arrays
The Array Visualization Tool
Using Python Lists to Implement the Array Class
The Ordered Array Visualization Tool
Python Code for an Ordered Array Class
Logarithms
Storing Objects
Big O Notation
Why Not Use Arrays for Everything?
Summary
Questions
Experiments
Programming Projects

3. Simple Sorting
How Would You Do It?
Bubble Sort
Selection Sort
nsertion Sort
Comparing the Simple Sorts
Summary
Questions
Experiments
Programming Projects

4. Stacks and Queues


Different Structures for Different Use Cases
Stacks
Queues
Priority Queues
Parsing Arithmetic Expressions
Summary
Questions
Experiments
Programming Projects

5. Linked Lists
Links
The Linked List Visualization Tool
A Simple Linked List
Linked List Efficiency
Abstract Data Types and Objects
Ordered Lists
Doubly Linked Lists
Circular Lists
terators
Summary
Questions
Experiments
Programming Projects
6. Recursion
Triangular Numbers
Factorials
Anagrams
A Recursive Binary Search
The Tower of Hanoi
Sorting with mergesort
Eliminating Recursion
Some Interesting Recursive Applications
Summary
Questions
Experiments
Programming Projects

7. Advanced Sorting
Shellsort
Partitioning
Quicksort
Degenerates to O(N2) Performance
Radix Sort
Timsort
Summary
Questions
Experiments
Programming Projects

8. Binary Trees
Why Use Binary Trees?
Tree Terminology
An Analogy
How Do Binary Search Trees Work?
Finding a Node
nserting a Node
Traversing the Tree
Finding Minimum and Maximum Key Values
Deleting a Node
The Efficiency of Binary Search Trees
Trees Represented as Arrays
Printing Trees
Duplicate Keys
The BinarySearchTreeTester.py Program
The Huffman Code
Summary
Questions
Experiments
Programming Projects

9. 2-3-4 Trees and External Storage


ntroduction to 2-3-4 Trees
The Tree234 Visualization Tool
Python Code for a 2-3-4 Tree
Efficiency of 2-3-4 Trees
-3 Trees
External Storage
Summary
Questions
Experiments
Programming Projects

10. AVL and Red-Black Trees


Our Approach to the Discussion
Balanced and Unbalanced Trees
AVL Trees
The Efficiency of AVL Trees
Red-Black Trees
Using the Red-Black Tree Visualization Tool
Experimenting with the Visualization Tool
Rotations in Red-Black Trees
nserting a New Node
Deletion
The Efficiency of Red-Black Trees
-3-4 Trees and Red-Black Trees
Red-Black Tree Implementation
Summary
Questions
Experiments
Programming Projects

11. Hash Tables


ntroduction to Hashing
Open Addressing
Separate Chaining
Hash Functions
Hashing Efficiency
Hashing and External Storage
Summary
Questions
Experiments
Programming Projects

12. Spatial Data Structures


Spatial Data
Computing Distances Between Points
Circles and Bounding Boxes
Searching Spatial Data
Lists of Points
Grids
Quadtrees
Theoretical Performance and Optimizations
Practical Considerations
Further Extensions
Summary
Questions
Experiments
Programming Projects

13. Heaps
ntroduction to Heaps
The Heap Visualization Tool
Python Code for Heaps
A Tree-Based Heap
Heapsort
Order Statistics
Summary
Questions
Experiments
Programming Projects

14. Graphs
ntroduction to Graphs
Traversal and Search
Minimum Spanning Trees
Topological Sorting
Connectivity in Directed Graphs
Summary
Questions
Experiments
Programming Projects

15. Weighted Graphs


Minimum Spanning Tree with Weighted Graphs
The Shortest-Path Problem
The All-Pairs Shortest-Path Problem
Efficiency
ntractable Problems
Summary
Questions
Experiments
Programming Projects

16. What to Use and Why


Analyzing the Problem
Foundational Data Structures
Special-Ordering Data Structures
Sorting
Specialty Data Structures
External Storage
Onward

Appendix A. Running the Visualizations


For Developers: Running and Changing the Visualizations
For Managers: Downloading and Running the Visualizations
For Others: Viewing the Visualizations on the Internet
Using the Visualizations

Appendix B. Further Reading


Data Structures and Algorithms
Object-Oriented Programming Languages
Object-Oriented Design (OOD) and Software Engineering

Appendix C. Answers to Questions


Chapter 1, “Overview”
Chapter 2, “Arrays”
Chapter 3, “Simple Sorting”
Chapter 4, “Stacks and Queues”
Chapter 5, “Linked Lists”
Chapter 6, “Recursion”
Chapter 7, “Advanced Sorting”
Chapter 8, “Binary Trees”
Chapter 9, “2-3-4 Trees and External Storage”
Chapter 10, “AVL and Red-Black Trees”
Chapter 11, “Hash Tables”
Chapter 12, “Spatial Data Structures”
Chapter 13, “Heaps”
Chapter 14, “Graphs”
Chapter 15, “Weighted Graphs”
Register your copy of Data Structures & Algorithms in Python at
informit.com for convenient access to downloads, updates, and corrections
as they become available. To start the registration process, go to
informit.com/register and log in or create an account. Enter the product
ISBN 9780134855684 and click Submit. Once the process is complete, you
will find any available bonus content under “Registered Products.”
Acknowledgments
From John Canning and Alan Broder
Robert Lafore’s Java-based version of this book has been a mainstay in
Data Structures courses and professionals’ reference shelves around the
world for many years. When Alan’s Data Structures course at Stern College
for Women of Yeshiva University moved on to Python, the inability to use
Lafore’s book in the course was a real loss. We’re thus especially happy to
bring this new and revised edition to the world of Python programmers and
students.
We’d like to thank the many students at Stern who contributed to this book
either directly or indirectly over the past several years. Initial Python
versions of Lafore’s Java implementations were central to Alan’s Python-
based courses, and Stern student feedback helped improve the code’s
clarity, enhanced its performance, and sometimes even identified and fixed
bugs!
For their valuable feedback and recommendations on early drafts of this
new edition, we are grateful to many students in Alan’s Data Structures
courses, including Estee Brooks, Adina Bruce, Julia Chase, Hanna Fischer,
Limor Kohanim, Elisheva Kohn, Shira Orlian, Shira Pahmer, Jennie Peled,
Alexandra Roffe, Avigail Royzenberg, Batia Segal, Penina Waghalter, and
Esther Werblowsky. Our apologies if we’ve omitted anyone’s name.
An open-source package of data structure visualizations is available to
enhance your study of this book, and Stern students played an active role in
the development of the visualization software. John and Alan extend many
thanks to the Stern student pioneers and leaders of this project, including
Ilana Radinsky, Elana Apfelbaum, Ayliana Teitelbaum, and Lily Polonetsky,
as well as the following past and present Stern student contributors: Zoe
Abboudi, Ayelet Aharon, Lara Amar, Natania Birnbaum, Adina Bruce,
Chani Dubin, Sarah Engel, Sarah Graff, Avigayil Helman, Michal
Kaufman, Sarina Kofman, Rachel Leiser, Talia Leitner, Shani Lewis, Rina
Melincoff, Atara Neugroschl, Shira Pahmer, Miriam Rabinovich, Etta Rapp,
Shira Sassoon, Mazal Schoenwald, Shira Schneider, Shira Smith, Riva
Tropp, Alexandra Volchek, and Esther Werblowsky. Our apologies if we
have left anyone off this list.
Many thanks go to Professor David Matuszek of the University of
Pennsylvania for his early contributions of ideas and PowerPoint slides
when Alan first started teaching Data Structures at Stern. Many of the slides
available in the Instructors Resources section have their origin in his clear
and well-designed slides. Also, we are grateful to Professor Marian Gidea
of the Department of Mathematics of Yeshiva University for his insights
into spherical trigonometry.
Finally, we owe a great debt to the talented editors at Pearson who made
this book a reality: Mark Taber, Kim Spenceley, Mandie Frank, and Chris
Zahn. Without their many talents and patient help, this project would just be
an odd collection of text files, drawings, and source code.
From Robert Lafore for the Java-based versions of the book

Acknowledgments to the First Edition


My gratitude for the following people (and many others) cannot be fully
expressed in this short acknowledgment. As always, Mitch Waite had the
Java thing figured out before anyone else. He also let me bounce the applets
off him until they did the job, and extracted the overall form of the project
from a miasma of speculation. My editor, Kurt Stephan, found great
reviewers, made sure everyone was on the same page, kept the ball rolling,
and gently but firmly ensured that I did what I was supposed to do. Harry
Henderson provided a skilled appraisal of the first draft, along with many
valuable suggestions. Richard S. Wright, Jr., as technical editor, corrected
numerous problems with his keen eye for detail. Jaime Niño, Ph.D., of the
University of New Orleans, attempted to save me from myself and
occasionally succeeded, but should bear no responsibility for my approach
or coding details. Susan Walton has been a staunch and much-appreciated
supporter in helping to convey the essence of the project to the
nontechnical. Carmela Carvajal was invaluable in extending our contacts
with the academic world. Dan Scherf not only put the CD-ROM together,
but was tireless in keeping me up to date on rapidly evolving software
changes. Finally, Cecile Kaufman ably shepherded the book through its
transition from the editing to the production process.

Acknowledgments to the Second Edition


My thanks to the following people at Sams Publishing for their competence,
effort, and patience in the development of this second edition. Acquisitions
Editor Carol Ackerman and Development Editor Songlin Qiu ably guided
this edition through the complex production process. Project Editor Matt
Purcell corrected a semi-infinite number of grammatical errors and made
sure everything made sense. Tech Editor Mike Kopak reviewed the
programs and saved me from several problems. Last but not least, Dan
Scherf, an old friend from a previous era, provides skilled management of
my code and applets on the Sams website.
About the Author
Dr. John Canning is an engineer, computer scientist, and researcher. He
earned an S.B. degree in electrical engineering from the Massachusetts
Institute of Technology and a Ph.D. in Computer Science from the
University of Maryland at College Park. His varied professions include
being a professor of computer science, a researcher and software engineer
in industry, and a company vice president. He now is president of
Shakumant Software.
Alan Broder is clinical professor and chair of the Department of Computer
Science at Stern College for Women of Yeshiva University in New York
City. He teaches introductory and advanced courses in Python
programming, data structures, and data science. Before joining Stern
College, he was a software engineer, designing and building large-scale
data analysis systems. He founded and led White Oak Technologies, Inc. as
its CEO, and later served as the chairman and fellow of its successor
company, Novetta, in Fairfax, Virginia.
Introduction
What’s in this book? This book is designed to be a practical introduction to
data structures and algorithms for students who have just begun to write
computer programs. This introduction will tell you more about the book,
how it is organized, what experience we expect readers will have before
starting the book, and what knowledge you will get by reading it and doing
the exercises.

Who This Book Is For


Data structures and algorithms are the core of computer science. If you’ve
ever wanted to understand what computers can do, how they do it, and what
they can’t do, then you need a deep understanding of both (it’s probably
better to say “what computers have difficulty doing” instead of what they
can’t do). This book may be used as a text in a data structures and/or
algorithms course, frequently taught in the second year of a university
computer science curriculum. The text, however, is also designed for
professional programmers, for high school students, and for anyone else
who needs to take the next step up from merely knowing a programming
language. Because it’s easy to understand, it is also appropriate as a
supplemental text to a more formal course. It is loaded with examples,
exercises, and supplemental materials, so it can be used for self-study
outside of a classroom setting.
Our approach in writing this book is to make it easy for readers to
understand how data structures operate and how to apply them in practice.
That’s different from some other texts that emphasize the mathematical
theory, or how those structures are implemented in a particular language or
software library. We’ve selected examples with real-world applications and
avoid using math-only or obscure examples. We use figures and
visualization programs to help communicate key ideas. We still cover the
complexity of the algorithms and the math needed to show how complexity
impacts performance.

What You Need to Know Before You Read This


Book
The prerequisites for using this book are: knowledge of some programming
language and some mathematics. Although the sample code is written in
Python, you don’t need to know Python to follow what’s happening. Python
is not hard to understand, if you’ve done some procedural and/or object-
oriented programming. We’ve kept the syntax in the examples as general as
possible,
More specifically, we use Python version 3 syntax. This version differs
somewhat from Python 2, but not greatly. Python is a rich language with
many built-in data types and libraries that extend its capabilities. Our
examples, however, use the more basic constructs for two reasons: it makes
them easier to understand for programmers familiar with other languages,
and it illustrates the details of the data structures more explicitly. In later
chapters, we do make use of some Python features not found in other
languages such as generators and list comprehensions. We explain what
these are and how they benefit the programmer.
Of course, it will help if you’re already familiar with Python (version 2 or
3). Perhaps you’ve used some of Python’s many data structures and are
curious about how they are implemented. We review Python syntax in
Chapter 1, “Overview,” for those who need an introduction or refresher. If
you’ve programmed in languages like Java, C++, C#, JavaScript, or Perl,
many of the constructs should be familiar. If you’ve only programmed
using functional or domain-specific languages, you may need to spend more
time becoming familiar with basic elements of Python. Beyond this text,
there are many resources available for novice Python programmers,
including many tutorials on the Internet.
Besides a programming language, what should every programmer know? A
good knowledge of math from arithmetic through algebra is essential.
Computer programming is symbol manipulation. Just like algebra, there are
ways of transforming expressions to rearrange terms, put them in different
forms, and make certain parts more prominent, all while preserving the
same meaning. It’s also critical to understand exponentials in math. Much
of computer science is based on knowing what raising one number to a
power of another means. Beyond math, a good sense of organization is also
beneficial for all programming. Knowing how to organize items in different
ways (by time, by function, by size, by complexity, and so on) is crucial to
making programs efficient and maintainable. When we talk about efficiency
and maintainability, they have particular meanings in computer science.
Efficiency is mostly about how much time it takes to compute things but can
also be about the amount of space it takes. Maintainability refers to the ease
of understanding and modifying your programs by other programmers as
well as yourself.
You’ll also need knowledge of how to find things on the Internet, download
and install software, and run them on a computer. The instructions for
downloading and running the visualization programs can be found in
Appendix A of this book. The Internet has made it very easy to access a
cornucopia of tools, including tools for learning programming and
computer science. We expect readers to already know how to find useful
resources and avoid sources that might provide malicious software.

What You Can Learn from This Book


As you might expect from its title, this book can teach you about how data
structures make programs (and programmers) more efficient in their work.
You can learn how data organization and its coupling with appropriate
algorithms greatly affect what can be computed with a given amount of
computing resources. This book can give you a thorough understanding of
how to implement the data structures, and that should enable you to
implement them in any programming language. You can learn the process
of deciding what data structure(s) and algorithms are the most appropriate
to meet a particular programming request. Perhaps most importantly, you
can learn when an algorithm and/or data structure will fail in a given use
case. Understanding data structures and algorithms is the core of computer
science, which is different from being a Python (or other language)
programmer.
The book teaches the fundamental data structures that every programmer
should know. Readers should understand that there are many more. These
basic data structures work in a wide variety of situations. With the skills
you develop in this book, you should be able to read a description of
another data structure or algorithm and begin to analyze whether or not it
will outperform or perform worse than the ones you’ve already learned in
particular use cases.
This book explains some Python syntax and structure, but it will not teach
you all its capabilities. The book uses a subset of Python’s full capabilities
to illustrate how more complex data structures are built from the simpler
constructs. It is not designed to teach the basics of programming to
someone who has never programmed. Python is a very high-level language
with many built-in data structures. Using some of the more primitive types
such as arrays of integers or record structures, as you might find in C or
C++, is somewhat more difficult in Python. Because the book’s focus is the
implementation and analysis of data structures, our examples use
approximations to these primitive types. Some Python programmers may
find these examples unnecessarily complex, knowing about the more
elegant constructs provided with the language in standard libraries. If you
want to understand computer science, and in particular, the complexity of
algorithms, you must understand the underlying operations on the
primitives. When you use a data structure provided in a programming
language or from one of its add-on modules, you will often have to know its
complexity to know whether it will work well for your use case.
Understanding the core data structures, their complexities, and trade-offs
will help you understand the ones built on top of them.
All the data structures are developed using object-oriented programming
(OOP). If that’s a new concept for you, the review in Chapter 1 of how
classes are defined and used in Python provides a basic introduction to
OOP. You should not expect to learn the full power and benefits of OOP
from this text. Instead, you will learn to implement each data structure as a
class. These classes are the types of objects in OOP and make it easier to
develop software that can be reused by many different applications in a
reliable way.
The book uses many examples, but this is not a book about a particular
application area of computer science such as databases, user interfaces, or
artificial intelligence. The examples are chosen to illustrate typical
applications of programs, but all programs are written in a particular
context, and that changes over time. A database program written in 1970
may have appeared very advanced at that time, but it might seem very
trivial today. The examples presented in this text are designed to teach how
data structures are implemented, how they perform, and how to compare
them when designing a new program. The examples should not be taken as
the most comprehensive or best implementation possible of each data
structure, nor as a thorough review of all the potential data structures that
could be appropriate for a particular application area.

Structure
Each chapter presents a particular group of data structures and associated
algorithms. At the end of the chapters, we provide review questions
covering the key points in the chapter and sometimes relationships to
previous chapters. The answers for these can be found in Appendix C,
“Answers to Questions.” These questions are intended as a self-test for
readers, to ensure you understood all the material.
Many chapters suggest experiments for readers to try. These can be
individual thought experiments, team assignments, or exercises with the
software tools provided with the book. These are designed to apply the
knowledge just learned to some other area and help deepen your
understanding.
Programming projects are longer, more challenging programming exercises.
We provide a range of projects of different levels of difficulty. These
projects might be used in classroom settings as homework assignments.
Sample solutions to the programming projects are available to qualified
instructors from the publisher.

History
Mitchell Waite and Robert Lafore developed the first version of this book
and titled it Data Structures and Algorithms in Java. The first edition was
published in 1998, and the second edition, by Robert, came out in 2002.
John Canning and Alan Broder developed this version using Python due to
its popularity in education and commercial and noncommercial software
development. Java is widely used and an important language for computer
scientists to know. With many schools adopting Python as a first
programming language, the need for textbooks that introduce new concepts
in an already familiar language drove the development of this book. We
expanded the coverage of data structures and updated many of the
examples.
We’ve tried to make the learning process as painless as possible. We hope
this text makes the core, and frankly, the beauty of computer science
accessible to all. Beyond just understanding, we hope you find learning
these ideas fun. Enjoy yourself!
1. Overview
You have written some programs and learned enough to think that
programming is fun, or at least interesting. Some parts are easy, and some parts
are hard. You’d like to know more about how to make the process easier, get
past the hard parts, and conquer more complex tasks. You are starting to study
the heart of computer science, and that brings up many questions. This chapter
sets the stage for learning how to make programs that work properly and fast. It
explains a bunch of new terms and fills in background about the programming
language that we use in the examples.

In This Chapter
• What Are Data Structures and Algorithms?
• Overview of Data Structures
• Overview of Algorithms
• Some Definitions
• Programming in Python
• Object-Oriented Programming

What Are Data Structures and Algorithms?


Data organizations are ways data is arranged in the computer using its various
storage media (such as random-access memory, or RAM, and disk) and how
that data is interpreted to represent something. Algorithms are the procedures
used to manipulate the data in these structures. The way data is arranged can
simplify the algorithms and make algorithms run faster or slower. Together, the
data organization and the algorithm form a data structure. The data structures
act like building blocks, with more complex data structures using other data
structures as components with appropriate algorithms.
Does the way data is arranged and the algorithm used to manipulate it make a
difference? The answer is a definite yes. From the perspective of
nonprogrammers, it often seems as though computers can do anything and do it
very fast. That’s not really true. To see why, let’s look at a nonprogramming
example.
When you cook a meal, a collection of ingredients needs to be combined and
manipulated in specific ways. There is a huge variety of ways that you could
go about the individual steps needed to complete the meal. Some of those
methods are going to be more efficient than others. Let’s assume that you have
a written recipe, but are working in an unfamiliar kitchen, perhaps while
visiting a friend. One method for making the meal would be Method A:
1. Read through the full recipe noting all the ingredients it mentions, their
quantities, and any equipment needed to process them.
2. Find the ingredients, measure out the quantity needed, and store them.
3. Get out all the equipment needed to complete the steps in the recipe.
4. Go through the steps of the recipe in the order specified.
Let’s compare that to Method B:
1. Read the recipe until you identify the first set of ingredients or equipment
that is needed to complete the first step.
2. Find the identified ingredients or equipment.
3. Measure any ingredients found.
4. Perform the first step with the equipment and ingredients already found.
5. Return to the beginning of this method and repeat the instructions
replacing the word first with next. If there is no next step, then quit.
Both methods are complete in that that they should finish the complete recipe if
all the ingredients and equipment are available. For simple recipes, they should
take about the same amount of time too. The methods differ as the recipes get
more complex. For example, what if you can’t find the fifth ingredient? In
method A, that issue is identified at the beginning before any other ingredients
are combined. While neither method really explains what to do about
exceptions like a missing ingredient, you can still compare them under the
assumption that you handle the exceptions the same way.
A missing ingredient could be handled in several ways: find a substitute
ingredient, broaden the search for the ingredient (look in other rooms, ask a
neighbor, go to the market), or ignore the ingredient (an optional garnish). Each
of those remedies takes some time. If there is one missing ingredient and two
cooks using the different methods handle it in the same way, both are delayed
the same amount of time. If there are multiple missing ingredients, however,
Method A should identify those earlier and allow for the possibility of getting
all the missing ingredients in one visit to a neighbor or a market. The time
savings of combining the tasks of replacing missing ingredients could be
significant (imagine the market being far away or neighbors who want to talk
for hours on every visit).
The order of performing the operations could have significant impact on the
time needed to complete the meal. Another difference could be in the quality of
the meal. For example, in Method B the cook would perform the first “step”
and then move on to the next step. Let’s assume those use two different groups
of ingredients or equipment. If finding or measuring the ingredients, or getting
the equipment for the later steps takes significant time, then the results of the
first step sit around for a significant time. That can have a bad effect on the
quality of the meal. The cook might be able to overcome that effect in some
circumstances by, say, putting the results of the first step in a freezer or
refrigerator and then bringing them back to room temperature later. The cook
would be preserving the quality of the food at the expense of the time needed
to prepare it.
Would Method B ever be desirable if it takes longer or risks degrading the
quality of the food? Perhaps. Imagine that the cook is preparing this meal in the
unfamiliar kitchen of a family relative. The kitchen is full of family members,
and each one is trying to make part of the meal. In this crowded situation, it
could be difficult for each cook to get out all of their ingredients and equipment
at once. There might not be enough counter space, or mixing bowls, or knives,
for example, for each cook to have all their items assembled at the beginning.
The cooks could be constrained to work on individual steps while waiting for
equipment, space, or ingredients to become available. In this case, Method B
could have advantages over asking all the cooks to work one at a time using
Method A.
Coming back to programming, the algorithm specifies the sequence of
operations that are to be performed, much like the steps in the recipe. The data
organizations are somewhat analogous to how the ingredients are stored, laid
out in the kitchen, and their proximity to other ingredients and equipment. For
example, having the ingredient in the kitchen makes the process much faster
than if the ingredient needs to be retrieved from a neighbor or the market. You
can think of the amount of space taken up by spreading out the ingredients in
various locations as the amount of space needed for the algorithm. Even if all
the ingredients are in the kitchen where the cook is, there are ways of setting up
the ingredients to make the cooking tasks go faster. Having them compactly
arranged in the order they are needed minimizes the amount of moving around
the cook must do. The organization of the ingredients can also help if a cook
must be replaced by another cook in the middle of the preparation;
understanding where each of the ingredients fits in to the recipe is faster if the
layout is organized. This is another reason why good data organization is
important. It also reinforces that concept that the algorithm and the data
organization work together to make the data structure.
Data structures are important not just for speed but also to properly model the
meaning of the data. Let’s say there’s an event that many people want to attend
and they need to submit their phone number to have a chance to get tickets.
Each person can request multiple tickets. If there are fewer tickets than the
number of people who want to get them, some method needs to be applied to
decide which phone numbers to contact first and determine the number of
tickets they will receive. One method would be to go through the phone
numbers one at a time and total up the number of tickets until all are given out,
then go through the remaining numbers to let them know the tickets are gone.
That might be a fair method if the numbers were put in an ordered list defined
in a way that potential recipients understood— for example, a chronological
list of phone numbers submitted by people interested in the tickets. If the
tickets are to be awarded as a sort of lottery, then going through them
sequentially means following any bias that is implicit in the order of the list.
Randomly choosing a number from the list, contacting the buyer, and then
removing the number would be fairer in a lottery system.
Data structures model systems by assigning specific meanings to each of the
pieces and how they interact. The “systems” are real-world things like first-
come, first-served ticket sales, or a lottery giveaway, or how roads connect
cities. For the list of phone numbers with ticket requests, a first-come, first-
served system needs the list in chronological order, some pointer to where in
the list the next number should be taken, and a pointer to where any newly
arriving number should be added (after all previous list entries). The lottery
system would need a different organization, and modeling the map of roads and
cities needs another. In this book we examine a lot of different data structures.
Each one has its strengths and weaknesses and is applicable to different kinds
of real-world problems. It’s important to understand how each one operates,
whether it correctly models the behavior needed by a particular problem area,
whether it will operate efficiently to perform the operations, and whether it can
“scale” well. We say a data structure or algorithm scales well if it will perform
as efficiently as possible as the amount of data grows.

Overview of Data Structures


As we’ve discussed, not every data structure models every type of problem. Or
perhaps a better way to put it is that the structures model the problem
awkwardly or inefficiently. You can generalize the data structures somewhat by
looking at the common operations that you are likely to do across all of them.
For example, to manage the requests for tickets, you need to
• Add a new phone number (for someone who wants one or more tickets)
• Remove a phone number (for someone who later decides they don’t want
tickets)
• Find a particular phone number (the next one to get a ticket by some
method, or to look up one by its characteristics)
• List all the phone numbers (show all the phone numbers exactly once,
that is, without repeats except, perhaps, for cases where multiple
identical entries were made)
These four operations are needed for almost every data structure that manages
a large collection of similar items. We call them insertion, deletion, search,
and traversal.
Here’s a list of the data structures covered in this book and some of their
advantages and disadvantages with respect to the four operations. Table 1-1
shows a very high-level view of the structures; we look at them in much more
detail in the following chapters. One aspect mentioned in this table is the data
structure’s complexity. In this context, we’re referring to the structure’s ability
to be understood easily by programmers, not how quickly it can be
manipulated by the computer.
Table 1-1 Comparison of Different Data Types
Overview of Algorithms
Algorithms are ways to implement an operation using a data structure or group
of structures. A single algorithm can sometimes be applied to multiple data
structures with each data structure needing some variations in the algorithm.
For example, a depth first search algorithm applies to all the tree data
structures, perhaps the graph, and maybe even stacks and queues (consider a
stack as a tree with branching factor of 1). In most cases, however, algorithms
are intimately tied to particular data structures and don’t generalize easily to
others. For example, the way to insert new items or search for the presence of
an item is very specific to each data structure. We examine the algorithms for
insertion, search, deletion, and traversal for all the data structures. That
illustrates how much they vary by data structure and the complexity involved
in those structures.
Another core algorithm is sorting, where a collection of items is put in a
particular order. Ordering the items makes searching for items faster. There are
many ways to perform sort operations, and we devote Chapter 3, “Simple
Sorting,” to this topic, and revisit the problem in Chapter 7, “Advanced
Sorting.”
Algorithms are often defined recursively, where part of the algorithm refers to
executing the algorithm again on some subset of the data. This very important
concept can simplify the definition of algorithms and make it very easy to
prove the correctness of an implementation. We study that topic in more detail
in Chapter 6, “Recursion.”

Some Definitions
This section provides some definitions of key terms.

Database
We use the term database to refer to the complete collection of data that’s
being processed in a particular situation. Using the example of people
interested in tickets, the database could contain the phone numbers, the names,
the desired number of tickets, and the tickets awarded. This is a broader
definition than what’s meant by a relational database or object-oriented
database.
Record
Records group related data and are the units into which a database is divided.
They provide a format for storing information. In the ticket distribution
example, a record could contain a person’s name, a person’s phone number, a
desired number of tickets, and a number of awarded tickets. A record typically
includes all the information about some entity, in a situation in which there are
many such entities. A record might correspond to a user of a banking
application, a car part in an auto supply inventory, or a stored video in a
collection of videos.

Field
Records are usually divided into several fields. Each field holds a particular
kind of data. In the ticket distribution example, the fields could be as shown in
Figure 1-1.

Figure 1-1 A record definition for ticket distribution


The fields are named and have values. Figure 1-1 shows an empty box
representing the storage space for the value. In many systems, the type of value
is restricted to a single or small range of data types, just like variables are in
many programming languages. For example, the desired number of tickets
could be restricted to only integers, or only non-negative integers. In object-
oriented systems, objects often represent records, and each object’s attributes
are the fields of that record. The terminology can be different in the various
programming languages. Object attributes might be called members, fields, or
variables.

Key
When searching for records or sorting them, one of the fields is called the key
(or search key or sort key). Search algorithms look for an exact match of the
key value to some target value and return the record containing it. The program
calling the search routine can then access all the fields in the record. For
example, in the ticket distribution system, you might search for a record by a
particular phone number and then look at the number of desired tickets in that
record. Another kind of search could use a different key. For example, you
could search for a record using the desired tickets as search key and look for
people who want three tickets. Note in this case that you could define the
search to return the first such record it finds or a collection of all records where
the desired number of tickets is three.

Databases vs. Data Structures


The collection of records representing a database is going to require a data
structure to implement it. Each record within the database may also be
considered a data structure with its own data organization and algorithms. This
decomposition of the data into smaller and smaller units goes on until you get
to primitive data structures like integers, floating-point numbers, characters,
and Boolean values. Not all data structures can be considered databases; they
must support insertion, search, deletion, and traversal of records to implement a
database.

Programming in Python
Python is a programming language that debuted in 1991. It embraces object-
oriented programming and introduced syntax that made many common
operations very concise and elegant. One of the first things that programmers
new to Python notice is that certain whitespace is significant to the meaning of
the program. That means that when you edit Python programs, you should use
an editor that recognizes its syntax and helps you create the program as you
intend it to work. Many editors do this, and even editors that don’t recognize
the syntax by filename extension or the first few lines of text can often be
configured to use Python syntax for a particular file.

Interpreter
Python is an interpreted language, which means that even though there is a
compiler, you can execute programs and individual expressions and statements
by passing the text to an interpreter program. The compiler works by
translating the source code of a program into bytecode that is more easily read
by the machine and more efficient to process. Many Python programmers
never have to think about the compiler because the Python interpreter runs it
automatically, when appropriate.
Interpreted languages have the great benefit of allowing you to try out parts of
your code using an interactive command-line interpreter. There are often
multiple ways to start a Python interpreter, depending on how Python was
installed on the computer. If you use an Integrated Development Environment
(IDE) such as IDLE, which comes with most Python distributions, there is a
window that runs the command-line interpreter. The method for starting the
interpreter differs between IDEs. When IDLE is launched, it automatically
starts the command-line interpreter and calls it the Shell.
On computers that don’t have a Python IDE installed, you can still launch the
Python interpreter from a command-line interface (sometimes called a terminal
window, or shell, or console). In that command-line interface, type python and
then press the Return or Enter key. It should display the version of Python you
are using along with some other information, and then wait for you to type
some expression in Python. After reading the expression, the interpreter
decides if it’s complete, and if it is, computes the value of the expression and
prints it. The example in Listing 1-1 shows using the Python interpreter to
compute some math results.

Listing 1-1 Using the Python Interpreter to Do Math

$ python
Python 3.6.0 (default, Dec 23 2016, 13:19:00)
Type "help", "copyright", "credits" or "license" for more information.
>>> 2019 - 1991
28
>>> 2**32 - 1
4294967295
>>> 10**27 + 1
1000000000000000000000000001
>>> 10**27 + 1.001
1e+27
>>>

In Listing 1-1, we’ve colored the text that you type in blue italics. The first
dollar sign ($) is the prompt from command-line interpreter. The Python
Discovering Diverse Content Through
Random Scribd Documents
know how long and how ardently I have loved you; may I not, one
day, drop that epithet of Cousin?" Tony looked at Kate for some
reply. "Cousin Tony," said Catherine, summoning up all her courage,
"we can never be more than friends and cousins." Then Kate's brow
began to cool, but whenever Tony would press the matter, all he saw
was new blown blushes, for Kate had seen that Tim's eyes were
fastened upon her, and from Tony's eager gaze and manner, she well
knew a stranger's suspicions must be roused.

Gentle reader, I have told you thus much of Tony's courtship, that
you, as well as Tim, might see a few of Katy's blushes. She was as
delicately refined in thought and sentiment as you can possibly
conceive. Her's was

"A beautiful transparent skin,


Which never hides the blood, yet holds it in;"

so soft, and thin, and white, that you might perceive each pulse as it
ebbed and flowed; indeed, whenever her heart was excited by any
sudden emotion, the delicate ruby would come and go, till the
consciousness of blushing would make her doubly crimson. She
would endeavor to conceal her emotions,

"But o'er her bright brow flashed a tumult strange,


And into her clear cheek the blood was brought,
Blood red, as sunset summer clouds, which range
The verge of heaven."

Good reader, I hate formal introductions, and therefore I have not


introduced you formally to my heroine, but since I have let you into
the secret that Kate's foible was blushing, I must go a little further;
when she did blush, she had a habit, as if to cool her brow, of
parting her ringlets, and then, carelessly, throwing them back, there
wantonly hung
"Down her white neck, long floating auburn curls,
The least of which, would set ten poets raving."

You are not to consider this a description of Katy's person; when I


attempt such a delineation, it will be with a flourish of trumpets,
louder and longer than Joshua made, when he encompassed the
walls of Jericho and blew them into fragments. At present, you see
our Catherine in a simple, neat, white dress, which

"Like fleecy clouds about the moon, play'd 'round her."

All this time, Tim, that most notorious contemner of beauty, and the
man of all others who could most manfully resist loveliness, "in any
shape, in any mood," sat drinking in these unconscious exhibitions of
Katy's character and mind. He saw not Tony, much less did he hear
or imagine what he said. All he perceived was Catherine's face, and
those rich, floating curls. It was indeed cruel in Cupid to place him
there. At every succeeding blush, a poisoned arrow flew from his
silver bow, and Tim's poor heart fluttered in his bosom. Determining
for once, however, to out general Cupid, Tim gallantly resolved upon
a hasty flight; accordingly, he took himself across the little bridge,
and began sauntering away on the opposite hill.

About the same time, Catherine again insisted upon returning, and
Tony finding all effort at persuasion perfectly hopeless, began to put
upon the matter the best face he could muster. Taking his cousin's
arm he insisted she should vary the walk, by crossing to the other
side of the canal, and return to the city in that direction. Kate
expressed her uneasiness at crossing this insecure bridge, but as
Tony was importunate, she reluctantly consented, not desiring
farther to add to his mortification by a positive refusal. Tony, as a
man of gallantry naturally would do, placed Catherine upon the
soundest of the logs, he himself walking by her side on the weaker
of the two, not reflecting that the weaker log would much more
easily bear her weight than his. As fate would have it, Catherine
became alarmed by the trembling of the bridge, and leaned the
more heavily upon Tony for support, and as he was not in a mood to
care much whether he broke his own neck or not, he insisted upon
proving to his cousin, that the bridge was perfectly secure, and that
all her fears were totally groundless. So taking her by the arm, in a
careless way, and telling her gaily, "Now mind what you are about,"
he raised himself upon his feet several times, so as to produce an
oscillating motion in the log. At this moment, Tim had turned about
to cast one lingering look, merely to inquire with himself, what lassie
that might be, when perceiving the danger they were in, he shouted
at the top of his voice, "Take care!"—but it was too late,—down
went the log with a terrible crash, and poor Tony and sweet Kate
were precipitated into the water below, in the middle of the canal, at
the deepest point. If ever you have seen in the hand of some
ruthless urchin, an innocent bird (which he has just succeeded in
securing from his trap,) flurried, gasping and panting with fright, you
will have a correct idea of Katy. She gave one shriek as she fell, and
then rose almost breathless, gasping and panting in an agony of
alarm. Luckily the water was not more than waist deep. Tony went
down feet foremost, following the decayed timbers, (pity he had not
fallen on his head,) but Catherine, clinging to his arm at the time of
the accident, and having her support suddenly taken from her, was
precipitated at full length into the water. In an instant, Tim rushed to
the spot. Into the canal he went, and catching the terrified Kate in
his arms, he brought her safely to the shore. Tony did all he could,
but poor fellow he was completely involved among the broken
fragments, and though he strove to rescue Kate, it was as much as
he could do to extricate himself. Tim knew there was no danger of
Tony's drowning, and so he left him to struggle for himself, giving all
his attention to Kate, who was truly an object worthy of his care,
and yet not the less of his admiration. She, though thoroughly wet,
withal looked so grateful, and her countenance expressed so many
thanks, and her pitiable situation, together with the freshness of the
water, heightened the bloom of her cheek to such a degree, that Tim
never once noticed her dress. Well might he have imagined her the
beauteous Goddess Thetis, with her silvery drapery, as she issued
from her watery mansion. But when she took off her fragile bonnet,
to adjust her dishevelled hair, and he viewed

"O'er her white forehead the gilt tresses flow,


Like the rays of the sun on a hillock of snow,"

who could have blamed him, if he had given way to his raptures,
and exclaimed,

"My heart for a slave to gay Venus I've sold,


And bartered my freedom for ringlets of gold."

As for Tony, if you could have seen him, as he crept out of the water,
with his "long tailed blue," tapering to a point, and dripping like an
old rooster under a cart, on a rainy day, with his head up and his tail
down, you really would have pitied him; he knew not which way to
look, nor what to say. I have seen a dog caught in the act of killing
sheep; have seen a wet rat creeping out of a tub; and I saw the gay
Tony sneaking out of the canal after having been turned off by his
sweetheart, and each of these animals, dog, rat, and Tony, had the
same identical sickly phiz. The dog slunk to his kennel, the rat crept
to his hole, but Tony was forced to his mistress, who with all
imaginable sweetness forgave him in an instant. He ought, if he
could, to have crept into an augur hole and hid himself there forever.

However, finding Tim was an old friend of his, he thanked him kindly
for his timely assistance, and introduced him to her, of all others,
with whom Tim most desired some farther acquaintance.

In a little time, our three friends began to laugh the matter over as
well as they could, and being thoroughly drenched, they endeavored
to keep each other in countenance, on their way homeward. Tim
accompanied Kate to her door, and then, wishing she might
experience no farther inconvenience from her accident, and having
received a polite invitation to visit the family, retired with Tony to
procure a drier suit.
My kind reader, you must listen to me with patience; hereafter, I will
not ramble so much at large, but will hasten on with my story.
Time's magic wing sped on, and days, weeks and months rolled by.
In the mean time, Tim continued his visits to Kate. Sometimes, at an
interval of a fortnight; at other times but a week would elapse; then
this short week began to appear an entire month; finally, weeks
were reduced to days, and days to hours, and Tim was not satisfied
unless he paid a visit at least twice a day.

The gossips of the city were thus furnished with a new theme to run
riot with, and Tim and Catherine were bandied about at a merciless
rate. Some thought it passing strange—others thought it natural
enough. "Did you hear Mr. Wilberforce was courting?" said one; "Did
you know Miss Catherine was engaged?" said another; "I'll bet my
life they will be married!" "I know she has turned him off!" "She will
never have him in the world," said a third, "for she is already
engaged to her cousin Tony." And thus, Tim was known to be
courting, engaged, turned off and jilted, before he himself had
ascertained what his fate would be; but the latter opinion, that he
was certainly turned off, gained the more currency, particularly as
our friend was suddenly called off, by business, to a distant city,
where he was compelled to remain for several months. The busy
bodies could not but notice, with what a heavy heart he departed,
and there could be no possibility of doubt about it. Tim had certainly
received his walking papers. No matter, friend Tim, thou must learn

"What it is to admire and to love,


And to leave her we love and admire."

My best wishes attend thee wherever thou goest.

Most persons would suppose, that after the honest denial, and the
decent ducking Tony had obtained, that the ardor of his love would
have been somewhat cooled, and that he would have been the last
person who would ever have attempted again to mention love in
Catherine's presence. Not so, Tony. He had been more than once
rejected already by his cousin, but because they were cousins, and
Catherine had always treated him kindly, Tony was still induced to
harbor hope, when almost any other person would only have
welcomed despair. He found it impossible "to look and not to love."
He was one of those luckless wights, who love and are not beloved,
and yet cannot bring themselves to give up the loved object—who,
though driven from the presence of their fair ones, continue to cast
a lingering look behind, to catch a glimpse of relenting compassion.
He reminded me of the glowing description of Lot's wife, once given
by an humble divine, when he endeavored to explain to his flock
why it was that she continued to look back as she fled from the ill-
fated Sodom. "Ah, my brethren," he said, "no doubt the good
woman had a pleasant little garden there, filled with all kinds of
vegetables, and the remembrance of her greens, and her turnips,
her potatoes, tomatoes, her squashes and beans, about which she
had experienced many moments of anxiety and vexation, caused her
heart to cling to the world, and so from the top of every little knob,
she looked,—and looked,—and there she stands, a pillar of salt." If
Tony but received a look of recognition, it was sufficient
encouragement for him. If he accidentally received a civil bow, in
return for a gracious smile, he would imagine himself welcomed to
her arms. If he offered his hand, and she did not put her arms
akimbo, and look like a very virago, he would return the next
morning, and if he was again told of friendship merely, Tony would
only express his astonishment, and say, "Why then did you give me
such encouragement,—why did you look in that way?" Look in that
way! Now the fact is, no matter which way Catherine might have
looked, it would have been all the same to Tony. If she looked mild
and placid, or fierce and acid; if she had been pensive and musing,
or laughing and romping; had she looked out of her right eye
athwart her nose, or out of her left athwart her shoulder, or had she
not looked at all, "like Paddy, when he shut his eyes to peep in the
glass, to see how he looked when asleep," Tony would have
discovered ample cause for indulging in hope in each smile, frown,
curl of the lip, or play of a muscle. But though, continuing in the
same hopeless condition, he always consoled himself by saying,
"She gaz'd as I slowly withdrew,
My path I could hardly discern,
So sweetly she bade me adieu,
I thought that she bade me return."

Time still moved onward. And Catherine still attracted and received
the admiration of all who beheld her. One day, as she was seated
alone in her parlor, in a somewhat melancholy mood, (for it was a
rainy, dreary day,) with a book in her hand, her back to the door, and
her head leaning against the sash of the window, she began to hum
to herself a little song a friend had lately given her. She would sing a
line or two, and pause,—and then again would raise her mellow
voice.

"If he return not, ah, she said,


I'll bid adieu to Hope to-morrow."

And this was sung with so much feeling, you could plainly see her
heart had given utterance to its inmost sentiments. Her singing was
so sweet, we might truly say,

"It was the carol of a bird;


It ceased, and then it came again,
The sweetest song ear ever heard."

The notes however died away, and Kate still sat in a seeming
reverie. When we are fairly in one of these musing moods, we will sit
for hours, without being able to tell upon what object our eyes or
thoughts have been so keenly rivetted. Our senses seem to be
closed against ordinary impressions. At any rate, while Catherine
continued thus leaning, some one walked lightly into the room, and
discovering he was not noticed, gently placed his hands over her
eyes without speaking.

"Now, cousin Tony," said Kate, "none of your tricks; I am not in a


humor for trifling to-day." Tony was not satisfied with feeling cousin
Katy's eyes, but turning her head gently back, was feasting on the
face, which a little vexation had slightly ruffled. "I'll pay you for this,
Tony," she said, in a sprightlier tone, "I know it is you, so let me go."
Tony had often played this trick before. "I thought, after what
passed," said Kate, and she was about saying something harsh, but
checking herself, she added, "Never mind, Tony." "Indeed, Kate, it is
not Tony," said the gentleman, releasing his prisoner.

Reader, you have seen blushes! Had you been with me that day, you
would have witnessed "smiles playing with dimples, suffused with
blushes, Aurora alone could rival." You would have seen surprise and
joy chasing away sorrow from a pensive brow; and from the "joy
sparkling in their dark eyes like a gem," you would have sworn that
these were acknowledged lovers.

"Oh, there are looks and tones that dart


An instant sunshine through the heart."

Who do you think could have thus intruded and taken such a liberty,
other than cousin Tony? It was our old friend Timothy Wilberforce,
returned from his travels.

Any one of ordinary comprehension, who could have witnessed this


meeting, and seen these looks, would have felt no hesitation in
making affidavit to the fact, that Kate had not only never rejected
Tim, but that they were upon pretty reasonable terms.

Some of my fair readers, I have no doubt, have already determined,


if any engagement actually existed, that Tim was a cold, phlegmatic,
inanimate being, or he would have kissed her at every hazard. I
know one young lady, who jilted a beau, because he never offered
to salute her,—she "had no idea of icicles"—not she. And I know
another, who swears! (ladies never swear,) who "vows, 'pon honor,
she would turn off any man under the sun, who would have the
presumption to approach her with such an intention even." But if the
doors were closed, blinds drawn, and they were all alone, and she
was sure nobody could see them, I rather think it would not be quite
as shocking as some people might imagine. The fact is, my dear
madam, Tim was excessively remiss on this occasion, but he must
be excused, because, just as he was in the very act, with one hand
under Katy's chin, and the other at the back of her head, and just as
her little lips began to crimson, in came Katy's dear old aunty! I take
my oath, I would have gone the whole figure, and old aunt Tabby
might have gone to the ——. (I beg pardon.) Tim and Kate took it
out in looking, and

"In the large dark eyes mutual darted flame,"

enough was said and felt to compensate the loss.

Now, you must understand, that for some cause, I never could
divine what, aunt Tabby had taken up a mortal antipathy to our
friend Tim; indeed, she was his evil genius, and she always
managed to step in, at the very moment of all others, when her
company was least desired. If he paid a morning visit, and the rest
of the family kindly dropped off one by one, (each, by the bye,
making a lame excuse for his or her absence,) just as Tim would
draw up his chair close along side, and begin those endearments,
which all know how to use, but few to express,

"The gentle pressure and the thrilling touch,


The least glance, better understood than words,"

in would pop aunt Tabby, and down she would sit, like a cat at a
hole, and sit there for hours. Oh how Tim's heart would sicken. If he
made an evening call, and sat till all the family retired to repose,
good aunt Tabby did not think it proper for young ladies to be left
alone with young gentlemen; such things were not tolerated in her
day. Thus did the old lady keep her nightly vigils, rattling away about
ten thousand fooleries, and fretting honest Tim more than a legion
of devils, and at last, after vainly spending the evening, the poor
fellow would slowly depart, growling smothered curses:
"So turns the lion from the nightly fold,
Though high in courage, and with hunger bold,
Long galled by herdsmen, and long vex'd by hounds,
Stiff with fatigue, and fretted sore with wounds:
The darts fly round him from an hundred hands,
And the red terrors of the blazing brands:
'Till late, reluctant, at the dawn of day,
Sour he departs, and quits the untasted prey."

Some readers will say, "what difference would it make if aunt Tabby
was present?" I set all such down as utter boobies; for if any one
could carry on a courtship, or after engagement could carry on a
conversation with his intended, when the "Mother of Vinegar" was
present, in the shape of an old maid, and that old maid a sworn
enemy, I would unhesitatingly pronounce, that Cupid had nothing in
the world to do with the matter.

Tim and Kate however, found opportunities, at other times, to elude


even the vigilance of aunt Tabby, and the old lady finding matters
were going on swimmingly, in spite of her interruptions and vigils,
only became the more determined to break off the match, if it could
by possibility be accomplished. The dear old lady never failed to
whisper into Katy's ear, every idle slander that the fertility of her own
mind enabled her to invent, or that she accidentally picked up
among the malicious gossips of the neighborhood, and more than
once Katy's faith had been shaken by her plausible inventions.
Nevertheless, as yet, Tim was smoothly gliding on the unruffled
wave of happiness; all was quiet and calm, and but a few days had
elapsed since Kate appointed the period for the consummation of
their nuptials.

On a former occasion, when Tim and little Molly were engaged, my


readers will remember how Tim endeavored to break the matter to
his mother. How he began with a desire to have the old house in
which they lived, newly painted, and how, before they came to the
conclusion to do so, the matter was suddenly terminated, by the
unlucky intrusion of a small friendly epistle, which not only rendered
it unnecessary to paint the house, but actually caused Tim to kick up
more dust and soot, than could be effaced by the best coat of
English lead that could be procured.

At the present juncture, the first intimation the old lady had of the
matter, was afforded her by an army of carpenters, bricklayers,
stone-masons and painters, scaling her house with ladders and
scaffolds, and turning the whole concern, topsy turvy, from the
garret to the cellar. Here ran the painters devils, rubbing every thing
with sand paper; there shouted the bricklayer, "mortar! bricks here!"
Here whistled the carpenter, and jarred the old timbers with his
hammer, banging and whacking away with the force of a giant.

"In the name of common sense," said the old lady, "good people
what do you mean?" If ever you saw a hen fluttering when a hawk
made a sudden dart at one of her brood, you would have some idea
of the old lady on this memorable occasion. It was as plain as the
nose in her face, that something was to pay, and she half suspected
what it was; but that Tim should go to work without any
consultation was unaccountable, and more than that, it was
unreasonable. She hallooed for Tim; he was not forthcoming. She
asked the carpenter what he was about? "Mr. Wilberforce had
ordered him to mend every thing that required mending." She
inquired of the bricklayer what he was doing? "Mr. Wilberforce told
him to cap the chimnies, relay the hearths and mend the whole
concern." She asked the painter what he meant by all this
preparation? "Mr. Wilberforce sent him to paint the house all over."
"You must have made a mistake in the house," said Tim's mother.
"No—there was no mistake. It was to be done, and in the best style,
and in the shortest possible time." The old lady packed off the
servants in all directions for Tim, and in the mean time continued
fluttering about, stowing away this thing and that thing, into this
hole and that cuddy, until she had fatigued herself into a perfect
fever. At length, Tim arrived. "My dear son," said she, "what in the
world has got into you? Do you mean to ruin yourself, Tim?"
"Mother," says Tim, kindly, "I told you I was going to be married."
"No you did'nt." "Well, I tell you so now, and I think our house wants
a little furbishing." Now, the old lady had frequently of late, been
charging Tim with being in love with Kate, and though he never
exactly denied it, yet he never had admitted it; and though she had
no decided objection to the match, yet she never had made up her
mind to it, and therefore she seated herself and began to cry. She
did'nt ask Tim, who he was to marry? Where the young lady lived?
What she was like? Whether she had a fortune or not? But she sat
down, as one bereft of all hope, and tuned up her pipes. Alas for
Tim! He had been too precipitate. Such matters require some
introduction.

The truth was, nothing could give the old lady so much happiness,
as to contribute in any way to Tim's comfort and felicity, or to know
that he was happy; but then, she and Tim had lived so long
together, now that he was going to be married, it seemed to her as
though she and he were to be divorced forever, and a thousand
conflicting feelings rushed into her bosom. Tim asked his mother if
she was dissatisfied with the match? "No," she said, in a tone of
inextinguishable grief, and then burst forth into fresh weeping.

Now, gentle reader, I have told you that the painters were making
terrible preparations for their work, and while Tim and his mother
were engaged, as we have just seen,—he, endeavoring to soothe
the old lady's unreasonable and ill-timed grief, and she, exhibiting as
much woe as she could possibly have done, had Tim been wrapped
in his winding sheet before her,—one of these aforesaid daubers
kept continually passing in and out at the door, until he had heard
enough to satisfy him that Tim was going to be married, and that
the old lady was most vehemently opposed to the match. He had
not heard her deny her opposition, but he had seen and heard her
weepings and wailings, which convinced him that she would never
consent to the match in the world. So, on his way home that day, he
happened to meet his cousin Patsy Wiggins, and stopping her in the
street,—"Did you know, cousin Patty, that young Mr. Wilberforce is
going to be married?" said brushy. "But I tell you what, it has kicked
up a terrible rumpus. I just left the old lady, breaking her heart
about it, and poor Mr. Tim is in a peck of troubles." Brushy went his
way, and so did cousin Patty, but meeting her dear friend Miss
Deborah Dobbins, as she was gossiping about the neighborhood;
"Ah, my dear Deb," says she, "have you heard the news? Old Mrs.
Wilberforce says, she will see her son in his grave, before she will
give her consent to his marrying, and what's more, Miss Catherine
Turberville shall never darken her doors while her head is hot. You
may rely upon it, they will have monstrous work of it." So off posted
the friendly Deborah Dobbins, to visit her crony, good Miss
Catherine's dear aunt Tabby. "Aunt Tabby," said Deb, "I am afraid I
have bad news to tell you." "What is it child?" "I know it will distress
you to hear it, but Mrs. Wilberforce has just heard that her son and
your niece are engaged, and she has told her son, in the most
peremptory manner, that her family shall never be disgraced by such
a connexion—that your niece is beneath his notice, and if he does
not break off the match immediately, he never more shall see her
face. Now, Mr. Tim swears he will marry her in spite of all opposition,
and so the whole house is in an uproar. If I were Kate, I'd let them
know who was disgraced."—"Beneath them!" said aunt Tabby,
turning up her nose until it nearly twisted over the back of her head
—"Beneath them, indeed!" "Darken her doors!" "She disgraced by
my niece!" "She!"

Gentle reader, you may readily imagine what else these good people
said and devised; but while this tale was going the rounds, gathering
as it rolled, Tim had entirely reconciled his mother to his intended
marriage, and as he unfolded his little plans, for his own and her
future comfort, the old lady cheered up and resumed her wonted
good humor.

The next day, Tim as usual, called to see his dearest Catherine, but
he was told she was not at home that morning. In the evening he
called again. "Miss Catherine was so unwell, she had taken to her
bed." Early the day after, Tim called to inquire how Catherine was.
"Tell Miss Catherine," said Tim, "I called to see her, and hope she is
better." Tim rambled about the lower part of the house. "Miss
Catherine was not so well." In this way, Tim called for several days,
vainly hoping to see his Kate, or at any rate to receive some kind
word or message. At last, he was honored with the following letter.

"Richmond, March 10th.

"I hope Mr. Wilberforce will pardon me for having denied myself
so often. At first, it was to me as painful as it could have been
to him, but if he knew the reason which prompted the course I
have adopted, he could not fail to applaud, what he now, no
doubt, condemns. In determining not to see him again, I have
consulted not only his peace, and the felicity of those dearest to
him, but I am convinced, my own happiness also. My reasons
would satisfy the most scrupulous—but as I cannot divulge
them, I must bear the scoffs of the world, for the fickleness and
coquetry which my conduct apparently justifies. I hope my
friend will bear this blow with becoming fortitude. The
determination I have made is painful to myself, but it is
irrevocable. If it will afford my friend any satisfaction to know,
that nothing that he has said or done, has produced this sudden
change in my purposes, I freely acknowledge the fact. He is in
every respect worthy of the best and loveliest. Forgive me, as
freely as I acquit you. Our engagement is terminated.

CATHERINE TURBERVILLE."

Tim sat down,—his elbow on the table,—his head on his hand.

For the Southern Literary Messenger.


MY TONGS. BY ——.

During the very cold weather which ushered in our last spring, I was
one night sitting in my dormitory, before a blazing fire, luxuriating in
that most selfish of all pleasures, vulgo a "brown study." There was
something so indescribably comfortable in my situation, that,
although I had half a dozen unprepared lectures for the next
morning staring me in the face, I found it a matter of utter
impossibility to open a text book, still less to direct my attention
even for the shortest time to its contents. Stretched in my capacious
arm chair—my feet toasting before the aforesaid blazing fire—I lay
listening with a dreamy sort of consciousness, to the continual, dull,
unceasing hum of the falling snow. Regardless and entirely
independent of the cold and storm without, my eyes fixed on the
fanciful figures, changeable as the images of the Kaleidescope,
which the burning coals assumed—in a word, settled in that position,
a description of which has been so often attempted—and which
every man who has one particle of soul about him has often and
oftentimes enjoyed, I fell into a long train of reflections as absorbing
and delightful as they were false and illusory. The future—the
present—the past—castles in the air—my far distant home—were the
most prominent and strongly marked images in the scenes which
flitted across the magic mirror of my fancy.

"I thought about myself and the whole earth,


Of man the wonderful, and of the stars,
And how the deuce they ever could have birth;
And then I thought of earthquakes and of wars;
How many miles the moon might have in girth;
Of air balloons, and of the many bars
To perfect knowledge—of the boundless skies."

I know not how long I had been in this situation, when my dreaming
was suddenly interrupted in a most singular manner. My tongs,
which were but little removed from the direct line of my vision,
seemed suddenly to become extremely uneasy. The simple,
unoffending tongs, which, except when used, had quietly occupied
their allotted station in the corner during the whole session,
appeared to be seized with a strange propensity for locomotion, and
at the same time to be altering the figure of their outward self in a
manner singular, wonderful, unaccountable. The general appearance
—the "tout ensemble" was, it is true, nearly the same, but still there
seemed to have been effected a certain change, which attracted my
wandering attention rather more immediately towards them. You
may smile perhaps, and say that either I was rather light headed, or
that I was neither more nor less than dreaming in reality. But there
before my eyes, which were as wide awake as they are at this
moment, upon the round knob which I had so often and so
unceremoniously grasped, was as quaint and humorous a face as
ever came from the pencil of Hogarth. A slight glance now gave me
an insight into the whole figure. Imagine the long spindle legs cased
in a pair of rusty looking "shorts"—the body, what little there was of
it, surrounded by one of those comfortable old garments, which
have been, not inaptly denominated quaker coats—and the rest of
the clothing in strict keeping with a style which, all who can
recollect, or even have heard much of the good old days of our
grandfathers, will at once recognise. Just imagine, I say, this odd
figure, thus garmented up, and you will form a good idea of the
general appearance of my visiter—(For I cannot believe it was the
same boná fide pair of tongs, which are now so peacefully reposing
before me.) The first glance was sufficient for an introduction. A
slight start on my side, and a familiar "at home" sort of nod on his—
and all was settled. His first motion was to seat himself on my
fender, where he deliberately crossed his legs—his first remark was
on the subject that last engaged my thoughts. A voice sweet and
delightful as the first waking notes of distant serenade, but perfectly
full and distinct, stole over my enraptured senses.

"You will doubtless be surprised to learn that I have been listening to


your thoughts for the last half hour. But know" said he, a little
pompously I thought, "that if your breast had in it the imaginary
window of Momus, your slightest meditations would not be more
plain and open to inspection than they are to me now. They have
been running rather in a scattered and unconnected manner, but like
those of most young men, they are principally directed to your own
future destiny and the choice you are to make with regard to your
pursuits and efforts hereafter. In a word, as a matter of considerable
importance to yourself, you are weighing the comparative
advantages of political and literary fame. Both are sufficiently
attractive, but to most young men, and particularly to those of your
country, the former is especially enticing. Perhaps there are at times,
doubts resting upon the minds of all men, whether these attractions
are not far greater in anticipation than the reality would authorize.
Even if these doubts were well founded, I would not attempt to
damp your bright and delightful hopes, by pouring into your ears the
dull, cold voice of a desponding prophesy. But such is not the case.
The pleasure of possession is real, and though in our ignorance we
sometimes decide, that when a balance is struck between the bitter
and sweet, in that mixture called the enjoyment of honors, it is
heavy in favor of the former—though we hear the pursuit after
worldly honors daily decried as a chase after some gaudy and
painted insect, which, when gained with difficulty, when grasped
with all the fervor and delight of gratified success, vanishes from the
sight and leaves nothing behind but the pain and agony of its sting—
though men who have never enjoyed them, often condescend to pity
their unhappy possessors—still do I assure you that possession is
delightful—even as delightful perhaps as your wildest dreams may
have painted it. The very eagerness with which all strive for it, who
can do so with any probability of success—the unconquerable
perseverance with which they hold it when obtained—are sufficient
proofs that it is worth the pursuit, and well rewards the winner. But
you have already decided on this point; perhaps your only doubts
are, upon which of the two principal (and in the present peaceful
days, I may almost say only,) roads to honor, will a man find the
best reward for the necessary exertions required to obtain it.
"The Hill of Fame on which your attention is fixed, is divided into two
summits. To the one every step of the path is plain, and open to
your view. You are at once sensible of the enjoyments as well as the
difficulties, which are found in the various parts of the ascent, while
those who journey upward are seen by all from the moment they
start. You perceive along this path the most delightful pleasures
awaiting those who may be so happy as to reach them—and
increasing in number as they rise. But you see dangers and
difficulties of every kind interspersed among them and also
increasing to the very top. The flowers when plucked have often a
poisonous insect enclosed in them—the finest fruit grows upon
precipices the most steep and frightful—or when gathered 'turns to
ashes in the mouth.' Yet in spite of these dangers you see many
rising free and uninjured, higher and higher, till they attain even to
the summit. But here, though pleasures are more abundant, the
dangers are likewise increased—though the flowers are more
beautiful and more numerous, the fruit large, and more delicious—
the poison is also more deadly, the precipices are higher, and the fall
from them more certainly fatal. But still is that summit, bright and
glorious as it is—the brilliant object on which is fixed the ardent,
anxious, devoted gaze of all who toil up the sides of the mountain.
This is the Hill of Political Fame. Now let us turn to the other; it
presents us quite a different aspect; its sides and bottom are
covered with a dim mist, through which no objects are distinctly
seen; we can only perceive that the way, though extremely steep
and laborious, is as free from the precipices and dangers of the first,
as it is deprived of its pleasures and enticements. Those who are
toiling on their way to its summit, have nothing to cheer them in
their dreary task but the prospect of the bright vision above them—
which like the beacon signal to the worn mariner, holds out comfort
and repose—cheering and inspiring him with fortitude—nerving his
limbs with new vigor, and instilling renewed hope into his heart. Nor
do you see them assailed by many imminent perils; yet many faint
and sink on their tedious way—and few, very few are so fortunate as
to gain the bright summit which rears its head above—free from the
shades and mists which envelope the skies—brilliant and glorious as
its opposite neighbor, and at the same time undisturbed by its
dangers. Even of those who do ultimately reach this rich goal of
their hopes—this happy end of their labors—how very few enjoy
their hard earned rewards—many of them supported alone by their
hopes on their wearisome journey—fall as soon as they reach the
top, and gain only after death the glorious distinction for which they
spent—to which they devoted their lives. This is the Hill of Literary
Fame.

"And now examine each and decide for yourself, which you will
choose as the scene of your future efforts—choose, and pursue that
choice with determination. One road alone can you follow. Some, it
is true, have, when tired of the one, pursued the other for a time.
But no man ever reached the top of both. You are then to decide in
favor of one, and having decided, steadily to pursue it, or content
yourself with remaining unnoticed in the crowd which fills the plain
beneath. That you may form your decision more correctly, look into
the history of those who have sought and gained pre-eminence, in
either kind of fame. Let us then (laying aside our metaphors) judge
from past history, and by that let your future course be decided. In
the histories of those who have even stood highest as writers, poets,
&c. you often find much calculated to disgust you with the pursuit
which they followed—how little do you find to envy in the lot of the
beggar Homer—the blind and half starved Milton—the miserable
Otway dying, choked with the morsel of food which he had begged
of a friend; Goldsmith, Johnson, &c. It is true, that in contrast to
these we may name Newton, Bacon, Shakspeare, Byron, who
succeeded in gaining during (and some of them early in) their lives
the fame they so eagerly sought. But more numerous are the
instances on record, where literary merit has been unrewarded
except by posthumous renown. Of genius the most brilliant—of
minds the most powerful, which have gained their hard earned mede
of praise—when their bodies were mouldering in the grave—when
the head which conceived, and the hand which penned their bright
aspirations, as well as the heart which so ardently beat for glory and
honor—have mingled with the dust, alike unmindful and indifferent
to praise or reproach, to fame or obloquy. When the bright etherial
spirit, which once so strongly throbbed for a 'name among men,' has
taken its flight to a truer home, where the glory of this world is
nothing—then is paid to the memory the honor which the man
deserved—which would have made him so completely happy. His life
perhaps was spent in grinding poverty, in misery and wretchedness,
imbittered by that chill cold neglect of the world, which so withers
the sensitive heart—for what? A name after death. Let us turn from
this dismal picture, to the other. Here at least, are some substantial
pleasures, however they may be alloyed by the attendant evils,
dangers and difficulties. Here at least, honor is nearly always
rendered, if bestowed at all, whilst it can be appreciated. And now
let us see whether the dangers and difficulties I have mentioned,
may not be really less than we were at first inclined to believe them,
and whether with care they may not be almost entirely avoided. It is
true, that he who once becomes a public servant, throws his
character in the hands of every man, and lays himself open to the
attacks of every scribbler. He is exposed to the malicious accusations
of men, who are neither able nor anxious to see his actions in their
true light; his slightest faults held up on high to become marks of
scorn among men—buts at which every vindictive slanderer may
wing a poisoned shaft—even his very virtues distorted and perverted
till they become in appearance vices. This I grant, is the life which all
public men must lead; but let not this picture startle you. If really
innocent, he will rise above the abuse which is poured upon him.
Confident in the great decision of a candid world, he is superior to
this sort of scandal. And have we not reason to believe that here as
in other cases, custom renders one indifferent to that which at first
would make him miserable? And that the most sensitive mind may
soon begin to look on these as troublesome insects, which may at
the time incommode, but which should create no lasting
disturbance. The best proof of this, as I have before told you is, that
men who have succeeded at all in public life, will, however
disagreeable it may appear, cling to it as strongly as if in this, lay the
very light of their existence. How sweet it is to have one's name in
the mouths of all—to be the theme of admiration and wonder with
the crowd—to have power. But there is even a purer and better
enjoyment. How perfect the pleasure which animates the bosom of
the statesman when he knows that to his talents—to his efforts—
millions are indebted for their greatest comforts—that a whole
nation looks up to him as their benefactor—that through his
means"——

My visiter had proceeded thus far, when a villainous log of wood


became suddenly discontented with its situation and rolled out upon
the hearth, scattering its sparks over me. Though deeply interested,
my first and most natural impulse was to grasp the tongs and set
every thing to rights. At the next instant my recollection returned
and I carefully replaced them. But it was too late. I saw nothing
before me but the cold and senseless instrument. The mild
expression of the features was gone—the quaint old figure had
vanished, and the faint sound of that sweet voice melted away on
my ear, like the dying ring of a harp, leaving me alone and
disconsolate in my solitary room.

For the Southern Literary Messenger.

TO MRS. ——,

Whose husband was absent in the United States Navy. On seeing her in a gay company.

Canst thou forget, amidst the gay and heartless,


One far away whom thou hast vowed to love?
Thou'rt lovely, and thou seemest pure and artless,
And innocent and gentle as the dove.
Dost thou forget, or do thy blue eyes brighten
Only with thoughts of his return to thee?
Dost thou the pains of absence seek to lighten,
In scenes like this of mirth and revelry?

Ah, pause awhile, mid sounds of song and dancing,


While thoughts of conscious beauty paint thy cheek,
While eyes, admiring eyes, around thee glancing,
Volumes of warmest admiration speak—
Think, if 'tis well for one whose faith is plighted,
To shine among the free unfettered gay—
Think, should those lovely eyes with smiles be lighted
At homage which no heart but one should pay?

Oh keep those smiles, so full of light and gladness,


To welcome one whom thou canst call thine own;
And may no darkling shade of gloom or sadness
Come o'er thy life, thou bright and peerless one!
E. A. S.

For the Southern Literary Messenger.

LINES WRITTEN IN AN ALBUM.

Eliza!—let thy generous heart


From its present pathway part not:
Being every thing which now thou art,
Be nothing which thou art not.

So with the world thy gentle ways—


Thy unassuming beauty—
And truth shall be a theme of praise
Forever—and love a duty.
E. A. P.

For the Southern Literary Messenger.

GENERAL WARREN.

STORIES ABOUT GENERAL WARREN—By a Lady of Boston, 1835, pp. 112, 12mo.

The sneers of those grown up readers,—who may choose to sneer at


a review of so very juvenile a book as this, we brave, for the sake of
bringing it, and its subject, somewhat into notice—pointing out some
phraseological errors—doing justice to its merits—and, above all,
freshening the memories, if not informing the minds, of the less
fastidious among our countrymen, as to a few of the incidents
preceding and attending the commencement of that great struggle,
of which the cherished remembrance conduces so much to preserve
in American bosoms a catholic, American, liberty-loving spirit. These
incidents will be found naturally to imbody themselves in a brief
account of the life of General Warren, drawn chiefly from the volume
above mentioned. Those who may incline to despise either so simple
a book, or a narrative of (to them) such trite facts, as these of which
we shall speak, are probably not aware how shallow and narrow is
the knowledge existing through the country, and even in some
minds that claim to be considered as enlightened, with regard to our
own history. "Mr. President!"—recently, at a public dinner in Virginia,
vociferated a young orator of the Milesian school—a lawyer, we took
him to be—"Mr. President! I give you, sir, the memory of the gallant
General Warren, who fell at the battle of LEXINGTON!" And but a
few months before, a friend as dear to us as ourselves, and whose
age and opportunities should certainly have made him know better,
confounded Sir William Berkeley, Governor of Virginia in the times of
Charles I and II, with Norborne Berkeley, Lord Botetourt, viceroy of
George III, in 1769 and 1770! It would not surprise us, to hear a
lawyer or a physician—still less a gentleman at large—talk of the
burning of Charleston as simultaneous with the battle of Sullivan's
Island, because Charlestown burned while the battle of Bunker Hill
was fighting—as "John Bull in America" passes in half an hour from
Boston, where the folk make wooden nutmegs, roast witches, and
bake pumpkin pies, into Charleston, where they gouge and stab,
drink mint juleps, eat young negroes, and feed old ones upon cotton
seed.

The narrative before us is couched in a dialogue, between a mother


and her two children; and, being obviously designed for gentlemen
and ladies not much higher than mamma's rocking chair, has
frequently an infantine simplicity of style, that makes us marvel at
our own moral courage, in daring to serve up such a baby's mess.
Convinced, however, that children's reading may afford both
amusement and instruction to grown people, (witness "Early
Lessons," "Frank," "The Parent's Assistant," "Sandford and Merton,"
and "Evenings at Home," cum pluribus aliis;) believing, at any rate,
that among the palates for which it is our duty to cater, there are
some youthful ones to which this dish may be both pleasant and
useful; hoping, too, that by having her faults of composition noted,
the authoress may be induced to cure, or "others in like cases
offending" be moved to shun them, we make the venture. Indeed,
not only the book's childishness of style, but many offences far more
atrocious in a critic's eyes—sins against grammar, idiom, and good
taste—are in great part redeemed by the good sense and justness of
its reflections, the interesting tenor of its incidents, and the virtuous
glow it is calculated to kindle. The sins are very many. "Lay," used
for "lie," is wholly unwarranted—scarcely palliated—even by the
example of Byron, in the Fourth Canto itself: for he was compelled
by duress of rhyme; a coercion, which the most tuneful and the
most dissonant are alike powerless to resist. "Mr. Warren, the father
of Joseph, while walking round his orchard to see if every thing was
in good order, as he was looking over the trees, he perceived," &c.
Here is a nominative without any verb. There is a four or five fold
vice in the second member of the following sentence, in which, as it
stands, the writer may be defied to show a meaning: "It often
happens that a mother is left with a family of young children, and is
obliged to bring them up without the controlling power of a father's
care; it is therefore the duty of every female so to educate her own
mind, and that of her daughters, as to enable her, if she should be
placed in this responsible situation, to be able to guide aright the
minds of those under her care." Enable her to be able! Educate her
own mind! and that of her daughters! Are they to be supposed to
have but one mind among them, as the Sirens had but one tooth?
The use of educate for train, is a match for the Frenchman's blunder,
who, finding in the Dictionary that to press means to squeeze,
politely begged leave to squeeze a lady to sing. "Enable HER." Enable
whom? Why herself and her daughters: and she should have said so.
Never, surely, was prosing, bona fide, printed prosing, to so little
purpose. Again: "A mother should always possess ... a firm principle
of action." Does she need but one firm principle of action? If so, it is
to be hoped the next edition will say what that one is; for it must be
valuable. A common blunder in the times of the infinitive mood,
occurs repeatedly in this book: "How I should have admired to have
gone to see her!" "It would have been a pity for us to have followed
his example, and thus have lessened," &c.—"must have ardently
desired to have been present"—"must have wished very much to
have seen," &c. We cannot see the propriety of using the word
"admired," as it is in one of these quotations. "Tell us if he did get in,
and how he contrived to?" We protest against this fashion which our
Yankee brethren are introducing, of making to, which is but the sign
of the infinitive, stand for the infinitive itself. This is one of the few
cases, in which we are for going the whole. "He began to
practice"—"I know it was not him"—"he whom I told you was the
first one"—"to respect, was added admiration and love"—"this tax
bore very heavy"—"soldiers which"—"your country has much to hope
from you, both in their counsels and in the field." These errors, a
very moderate skill in orthography and syntax would have sufficed to
avoid. Such a vulgarism as "nowadays," or such provincialisms as
"pay one single copper," and "walked back and forth the room,"
(meaning to and fro, or backwards and forwards in the room) would
not have occurred, if the author had remembered, that the simplicity
which suits children's minds, is altogether different from vulgarity.
There is such a thing as neat and graceful simplicity in writing, as
well as in dress and manners. "They had contemplated making some
attack on the British, or at least to endeavor to destroy their
shipping." Contemplated to destroy! We will not further pursue this
unwelcome task; pausing, short of the middle of the book, and
having already passed over several faults without animadversion. Let
the author be entreated to get the aid of some friend who is master
(if she is not mistress) of grammar and taste enough, to reform
these and the other errors of her little work, and then give us a new
edition, calling in all the copies of the first, that are within her reach.
—And now to our tale.

JOSEPH WARREN was born in 1741, in the village of Roxbury, one or


two miles south from Boston, Mass. His father, a rich farmer,
inhabited a house, the ruins of which are still visible; and was
famous for raising the best fruit in that neighborhood. He was killed
by a fall from one of his own apple trees, leaving a widow and four
sons, of whom Joseph, the eldest, was 16, and John, the youngest,
was 4 years old. This excellent woman appears to have much
resembled the mother of Washington, in the skill and care with
which she infused generous sentiments and virtuous principles into
the bosoms of her children: and she reaped almost as richly as Mrs.
Washington, the fruits of her labors. Her sons passed through life, all
honored and loved, and more than one of them distinguished. Her
nature seems to have had more of amiable softness than Mrs.
Washington's; who, it must be confessed, blended something of the
sternness with the purity and nobleness of a Spartan matron. Mrs.
Warren's door was always open for deeds of hospitality and
neighborly kindness. It is not easy to imagine a lovelier scene than
one paragraph presents, of the evening of a well spent life, still
warmed and brightened by the benign spirit, which had been the
sun of that life's long day.

"In her old age, when her own children had left her fireside, it was one of her dearest
pleasures to gather a group of their children, or of the children of others around her.
She did all in her power to promote their enjoyment, and her benevolent smile was
always ready to encourage them. On Thanksgiving-day,1 she depended on having all
her children and grand children with her; and until she was 80 years of age, she
herself made the pies with which the table was loaded! Not satisfied with feasting
them to their heart's content while they were with her, she always had some nice
great pies ready for them to take home with them."

1 Thanksgiving-day is in New England, what Christmas is in the Southern States and


England. It is always in November, on a day fixed by Proclamation of the Governor of
each State, in each year. Christmas, from the anti-Catholic zeal of the Puritan
Pilgrims, is almost entirely neglected; being, with all its train of quips, cranks,
gambols and mince-pies, thought to savor too strongly of popery.

Joseph's education, till his fourteenth year, was at the public school
in Roxbury; one of those common schools, which, from the earliest
times of New England, have been planting and nurturing in her soil
the seeds and shoots of virtue and freedom. Even in boyhood, our
hero was manly, fearless and generous: always taking the part of his
weaker school-fellows against a strong oppressor—always the

"village Hampden, that with dauntless breast,


The little tyrant of his fields withstood."

At fourteen, he entered Harvard University. His talents,


perseverance, gentleness and courage, here gained him unrivalled
popularity. That he did not acquire or preserve the regard of his
fellow students by any base compliances with vice or disorder, the
following incident shews.
Some of them had once resolved on some breach of the laws, which,
from the sturdiness of his principles, they knew that young Warren
would disapprove, and by his powerful influence probably prevent.
They therefore met in an upper room of the college, to arrange their
plans secretly; fastening the door against him. He found what they
were about; and seeing the window of their room open, crept out,
through a scuttle door, upon the roof—crawled to the eaves—and
there, seizing a water-spout nearly rotten with age, he swung and
slid down by it to the window, and unexpectedly sprang in amongst
the conspirators. The spout, at the instant of his quitting it, fell with
a crash to the ground, and was shivered to pieces. Only saying, in
answer to the exclamations of astonishment that burst from his
comrades, "it stayed up just long enough for my purpose," he
commenced an expostulation against their intended misdemeanor,
and succeeded in diverting them from it.

On leaving college, he studied medicine, and began to practise at


the age of 23, just previously to a visit of the small pox to Boston,
with those fearful ravages which usually attended its march, before
the virtues of vaccination were known. Dr. Warren's judgment,
tenderness, and skill, made him pre-eminently successful in treating
the disease. And it is said, that his gentle and courteous deportment
completely neutralized the usual tendency of such professional
success, to enkindle the jealousy of his brethren. His mild features
and winning smile, true indexes, for once, to the soul within, gained
every heart; his knowledge and talents added respect to love. Thus,
by the same qualities which had distinguished him at school and at
college, did he acquire among his fellow townsmen an influence
which no other man of his age and day possessed.

When the British Parliament and Crown began, in 1764, that course
of unconstitutional legislation, which was destined, after eleven
years of wordy war, to end in a war of blood, Dr. Warren was among
the first to stand forth for the rights of America—to assert, and to
labor in demonstrating to his countrymen, that the power to tax
them (claiming, as they did, all the liberties of Englishmen) could not
exist in a government of which no representatives of theirs formed a
part. Fostered by him, and by others like him, the spirit of resistance
to tyranny grew daily more strong. The inhabitants of the whole
country, and especially of Boston, gave token after token of their
fixed resolve, to spurn the chain which they saw preparing for them.
In 1768, Col. Dalrymple with two royal regiments, reinforced
afterwards by additional troops, entered that devoted town, with
more than the usual "pomp and circumstance" of military bravado;
and there remained in garrison, to repress what the king and
ministry were pleased to call "the seditious temper" of the people.
Never was attempt at restraint more impotent; nay, more suicidal.
The curb, feebly and capriciously or unskilfully plied, served but to
infuriate the noble animal it was meant to check and guide: and no
wonder that the rider was at length unseated, and stretched in the
dust. The New Englanders—we should rather say, the Americans—
were too stubborn to be driven, and too shrewd to be circumvented.
Every measure of tyranny, they met with an appropriate measure of
resistance. Tea had been brought from India, to be the vehicle of
unconstitutional taxation. They threw part of it into the sea; another
part they hindered from being landed; and the remainder they
excluded from use, by mutual pledges to "touch not, taste not" "the
unclean thing." Judges were sent over to judge them—creatures of
the king—the panders of ministerial oppression. The people would
not suffer them to mount the judgment seat—closed the court
houses—referred all their differences to arbitrators chosen by the
parties—and even so far tamed the spirit of litigation and disorder,
as to make tribunals of any sort in a great degree needless.2
Between the British troops and the Boston people, animosities soon
ran high. The soldiers seized every opportunity to exasperate the
people: the people assembled in mobs, to revenge themselves on
the soldiers. Amidst these tumults, Dr. Warren repeatedly exposed
his life to soothe and restrain his countrymen. His eloquent
persuasions were generally successful. At first, the more violent
would endeavor to repel him, and would clamor to drown his voice.
"While they did this, he would stand calmly and look at them. His
intrepidity, his commanding and animated countenance, and above

You might also like