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

Data Structures and Algorithm Analysis in Java 3rd Edition Dr. Clifford A. Shaffer instant download

The document provides information about the 3rd edition of 'Data Structures and Algorithm Analysis in Java' by Dr. Clifford A. Shaffer, including its digital download link and details such as ISBN, file size, and publication year. It outlines the contents of the book, covering various topics related to data structures, algorithms, and their analysis. Additionally, it includes links to other related textbooks and resources for further exploration.

Uploaded by

derkirapoto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
51 views

Data Structures and Algorithm Analysis in Java 3rd Edition Dr. Clifford A. Shaffer instant download

The document provides information about the 3rd edition of 'Data Structures and Algorithm Analysis in Java' by Dr. Clifford A. Shaffer, including its digital download link and details such as ISBN, file size, and publication year. It outlines the contents of the book, covering various topics related to data structures, algorithms, and their analysis. Additionally, it includes links to other related textbooks and resources for further exploration.

Uploaded by

derkirapoto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

Data Structures and Algorithm Analysis in Java

3rd Edition Dr. Clifford A. Shaffer pdf download

https://ebookfinal.com/download/data-structures-and-algorithm-
analysis-in-java-3rd-edition-dr-clifford-a-shaffer/

Explore and download more ebooks or textbooks


at ebookfinal.com
Here are some recommended products for you. Click the link to
download, or explore more at ebookfinal

Data Structures and Algorithm Analysis in Java 3rd Edition


Edition Mark A. Weiss

https://ebookfinal.com/download/data-structures-and-algorithm-
analysis-in-java-3rd-edition-edition-mark-a-weiss/

Data Structures and Algorithm Analysis in C 2nd Edition


China Reprint Edition Weiss

https://ebookfinal.com/download/data-structures-and-algorithm-
analysis-in-c-2nd-edition-china-reprint-edition-weiss/

Data Structures in Java A Laboratory Course 1st Edition


Sandra Andersen

https://ebookfinal.com/download/data-structures-in-java-a-laboratory-
course-1st-edition-sandra-andersen/

Data structures and algorithms in Java 2nd Edition Adam


Drozdek

https://ebookfinal.com/download/data-structures-and-algorithms-in-
java-2nd-edition-adam-drozdek/
Data Analysis of Asymmetric Structures Advanced Approaches
in Computational Statistics 1st Edition Takayuki Saito

https://ebookfinal.com/download/data-analysis-of-asymmetric-
structures-advanced-approaches-in-computational-statistics-1st-
edition-takayuki-saito/

Engineers Data Book Fourth Edition Clifford Matthews

https://ebookfinal.com/download/engineers-data-book-fourth-edition-
clifford-matthews/

Classic Data Structures Samanta

https://ebookfinal.com/download/classic-data-structures-samanta/

A Guide to Algorithm Design Paradigms Methods and


Complexity Analysis 1st Edition Anne Benoit (Author)

https://ebookfinal.com/download/a-guide-to-algorithm-design-paradigms-
methods-and-complexity-analysis-1st-edition-anne-benoit-author/

A Course in Miracles 3rd Edition Dr. Helen Schucman

https://ebookfinal.com/download/a-course-in-miracles-3rd-edition-dr-
helen-schucman/
Data Structures and Algorithm Analysis in Java 3rd
Edition Dr. Clifford A. Shaffer Digital Instant Download
Author(s): Dr. Clifford A. Shaffer
ISBN(s): 9780486485812, 0486485811
Edition: online ed. (601p., ver. 3.2.0.2, 15. Sept. 2011)
File Details: PDF, 2.65 MB
Year: 2011
Language: english
Data Structures and Algorithm
Analysis
Edition 3.2 (Java Version)

Clifford A. Shaffer
Department of Computer Science
Virginia Tech
Blacksburg, VA 24061

September 15, 2011


Update 3.2.0.2
For a list of changes, see
http://people.cs.vt.edu/˜shaffer/Book/errata.html

Copyright © 2009-2011 by Clifford A. Shaffer.


This document is made freely available in PDF form for educational and
other non-commercial use. You may make copies of this file and
redistribute in electronic form without charge. You may extract portions of
this document provided that the front page, including the title, author, and
this notice are included. Any commercial use of this document requires the
written consent of the author. The author can be reached at
shaffer@cs.vt.edu.
If you wish to have a printed version of this document, print copies are
published by Dover Publications
(see http://store.doverpublications.com/0486485811.html).
Further information about this text is available at
http://people.cs.vt.edu/˜shaffer/Book/.
Contents

Preface xiii

I Preliminaries 1

1 Data Structures and Algorithms 3


1.1 A Philosophy of Data Structures 4
1.1.1 The Need for Data Structures 4
1.1.2 Costs and Benefits 6
1.2 Abstract Data Types and Data Structures 8
1.3 Design Patterns 12
1.3.1 Flyweight 13
1.3.2 Visitor 13
1.3.3 Composite 14
1.3.4 Strategy 15
1.4 Problems, Algorithms, and Programs 16
1.5 Further Reading 18
1.6 Exercises 20

2 Mathematical Preliminaries 23
2.1 Sets and Relations 23
2.2 Miscellaneous Notation 27
2.3 Logarithms 29
2.4 Summations and Recurrences 30
2.5 Recursion 34
2.6 Mathematical Proof Techniques 36

iii
iv Contents

2.6.1 Direct Proof 37


2.6.2 Proof by Contradiction 37
2.6.3 Proof by Mathematical Induction 38
2.7 Estimation 44
2.8 Further Reading 45
2.9 Exercises 46

3 Algorithm Analysis 53
3.1 Introduction 53
3.2 Best, Worst, and Average Cases 59
3.3 A Faster Computer, or a Faster Algorithm? 60
3.4 Asymptotic Analysis 63
3.4.1 Upper Bounds 63
3.4.2 Lower Bounds 65
3.4.3 Θ Notation 66
3.4.4 Simplifying Rules 67
3.4.5 Classifying Functions 68
3.5 Calculating the Running Time for a Program 69
3.6 Analyzing Problems 74
3.7 Common Misunderstandings 75
3.8 Multiple Parameters 77
3.9 Space Bounds 78
3.10 Speeding Up Your Programs 80
3.11 Empirical Analysis 83
3.12 Further Reading 84
3.13 Exercises 85
3.14 Projects 89

II Fundamental Data Structures 91

4 Lists, Stacks, and Queues 93


4.1 Lists 94
4.1.1 Array-Based List Implementation 97
4.1.2 Linked Lists 100
4.1.3 Comparison of List Implementations 108
Contents v

4.1.4 Element Implementations 111


4.1.5 Doubly Linked Lists 112
4.2 Stacks 117
4.2.1 Array-Based Stacks 117
4.2.2 Linked Stacks 120
4.2.3 Comparison of Array-Based and Linked Stacks 121
4.2.4 Implementing Recursion 121
4.3 Queues 125
4.3.1 Array-Based Queues 125
4.3.2 Linked Queues 128
4.3.3 Comparison of Array-Based and Linked Queues 131
4.4 Dictionaries 131
4.5 Further Reading 138
4.6 Exercises 138
4.7 Projects 141

5 Binary Trees 145


5.1 Definitions and Properties 145
5.1.1 The Full Binary Tree Theorem 147
5.1.2 A Binary Tree Node ADT 149
5.2 Binary Tree Traversals 149
5.3 Binary Tree Node Implementations 154
5.3.1 Pointer-Based Node Implementations 154
5.3.2 Space Requirements 160
5.3.3 Array Implementation for Complete Binary Trees 161
5.4 Binary Search Trees 163
5.5 Heaps and Priority Queues 170
5.6 Huffman Coding Trees 178
5.6.1 Building Huffman Coding Trees 179
5.6.2 Assigning and Using Huffman Codes 185
5.6.3 Search in Huffman Trees 188
5.7 Further Reading 188
5.8 Exercises 189
5.9 Projects 192

6 Non-Binary Trees 195


vi Contents

6.1 General Tree Definitions and Terminology 195


6.1.1 An ADT for General Tree Nodes 196
6.1.2 General Tree Traversals 197
6.2 The Parent Pointer Implementation 199
6.3 General Tree Implementations 206
6.3.1 List of Children 206
6.3.2 The Left-Child/Right-Sibling Implementation 206
6.3.3 Dynamic Node Implementations 207
6.3.4 Dynamic “Left-Child/Right-Sibling” Implementation 210
6.4 K-ary Trees 210
6.5 Sequential Tree Implementations 212
6.6 Further Reading 215
6.7 Exercises 215
6.8 Projects 218

III Sorting and Searching 221

7 Internal Sorting 223


7.1 Sorting Terminology and Notation 224
7.2 Three Θ(n2 ) Sorting Algorithms 225
7.2.1 Insertion Sort 225
7.2.2 Bubble Sort 227
7.2.3 Selection Sort 229
7.2.4 The Cost of Exchange Sorting 230
7.3 Shellsort 231
7.4 Mergesort 233
7.5 Quicksort 236
7.6 Heapsort 243
7.7 Binsort and Radix Sort 244
7.8 An Empirical Comparison of Sorting Algorithms 251
7.9 Lower Bounds for Sorting 253
7.10 Further Reading 257
7.11 Exercises 257
7.12 Projects 261
Contents vii

8 File Processing and External Sorting 265


8.1 Primary versus Secondary Storage 265
8.2 Disk Drives 268
8.2.1 Disk Drive Architecture 268
8.2.2 Disk Access Costs 272
8.3 Buffers and Buffer Pools 274
8.4 The Programmer’s View of Files 282
8.5 External Sorting 283
8.5.1 Simple Approaches to External Sorting 285
8.5.2 Replacement Selection 288
8.5.3 Multiway Merging 290
8.6 Further Reading 295
8.7 Exercises 295
8.8 Projects 299

9 Searching 301
9.1 Searching Unsorted and Sorted Arrays 302
9.2 Self-Organizing Lists 307
9.3 Bit Vectors for Representing Sets 313
9.4 Hashing 314
9.4.1 Hash Functions 315
9.4.2 Open Hashing 320
9.4.3 Closed Hashing 321
9.4.4 Analysis of Closed Hashing 331
9.4.5 Deletion 334
9.5 Further Reading 335
9.6 Exercises 336
9.7 Projects 338

10 Indexing 341
10.1 Linear Indexing 343
10.2 ISAM 346
10.3 Tree-based Indexing 348
10.4 2-3 Trees 350
10.5 B-Trees 355
10.5.1 B+ -Trees 358
viii Contents

10.5.2 B-Tree Analysis 364


10.6 Further Reading 365
10.7 Exercises 365
10.8 Projects 367

IV Advanced Data Structures 369

11 Graphs 371
11.1 Terminology and Representations 372
11.2 Graph Implementations 376
11.3 Graph Traversals 380
11.3.1 Depth-First Search 383
11.3.2 Breadth-First Search 384
11.3.3 Topological Sort 384
11.4 Shortest-Paths Problems 388
11.4.1 Single-Source Shortest Paths 389
11.5 Minimum-Cost Spanning Trees 393
11.5.1 Prim’s Algorithm 393
11.5.2 Kruskal’s Algorithm 397
11.6 Further Reading 399
11.7 Exercises 399
11.8 Projects 402

12 Lists and Arrays Revisited 405


12.1 Multilists 405
12.2 Matrix Representations 408
12.3 Memory Management 412
12.3.1 Dynamic Storage Allocation 414
12.3.2 Failure Policies and Garbage Collection 421
12.4 Further Reading 425
12.5 Exercises 426
12.6 Projects 427

13 Advanced Tree Structures 429


13.1 Tries 429
Contents ix

13.2 Balanced Trees 434


13.2.1 The AVL Tree 435
13.2.2 The Splay Tree 437
13.3 Spatial Data Structures 440
13.3.1 The K-D Tree 442
13.3.2 The PR quadtree 447
13.3.3 Other Point Data Structures 451
13.3.4 Other Spatial Data Structures 453
13.4 Further Reading 453
13.5 Exercises 454
13.6 Projects 455

V Theory of Algorithms 459

14 Analysis Techniques 461


14.1 Summation Techniques 462
14.2 Recurrence Relations 467
14.2.1 Estimating Upper and Lower Bounds 467
14.2.2 Expanding Recurrences 470
14.2.3 Divide and Conquer Recurrences 472
14.2.4 Average-Case Analysis of Quicksort 474
14.3 Amortized Analysis 476
14.4 Further Reading 479
14.5 Exercises 479
14.6 Projects 483

15 Lower Bounds 485


15.1 Introduction to Lower Bounds Proofs 486
15.2 Lower Bounds on Searching Lists 488
15.2.1 Searching in Unsorted Lists 488
15.2.2 Searching in Sorted Lists 490
15.3 Finding the Maximum Value 491
15.4 Adversarial Lower Bounds Proofs 493
15.5 State Space Lower Bounds Proofs 496
15.6 Finding the ith Best Element 499
x Contents

15.7 Optimal Sorting 501


15.8 Further Reading 504
15.9 Exercises 504
15.10Projects 507

16 Patterns of Algorithms 509


16.1 Dynamic Programming 509
16.1.1 The Knapsack Problem 511
16.1.2 All-Pairs Shortest Paths 513
16.2 Randomized Algorithms 515
16.2.1 Randomized algorithms for finding large values 515
16.2.2 Skip Lists 516
16.3 Numerical Algorithms 522
16.3.1 Exponentiation 523
16.3.2 Largest Common Factor 523
16.3.3 Matrix Multiplication 524
16.3.4 Random Numbers 526
16.3.5 The Fast Fourier Transform 527
16.4 Further Reading 532
16.5 Exercises 532
16.6 Projects 533

17 Limits to Computation 535


17.1 Reductions 536
17.2 Hard Problems 541
17.2.1 The Theory of N P-Completeness 543
17.2.2 N P-Completeness Proofs 547
17.2.3 Coping with N P-Complete Problems 552
17.3 Impossible Problems 555
17.3.1 Uncountability 556
17.3.2 The Halting Problem Is Unsolvable 559
17.4 Further Reading 561
17.5 Exercises 562
17.6 Projects 564

Bibliography 567
Contents xi

Index 573
Preface

We study data structures so that we can learn to write more efficient programs.
But why must programs be efficient when new computers are faster every year?
The reason is that our ambitions grow with our capabilities. Instead of rendering
efficiency needs obsolete, the modern revolution in computing power and storage
capability merely raises the efficiency stakes as we attempt more complex tasks.
The quest for program efficiency need not and should not conflict with sound
design and clear coding. Creating efficient programs has little to do with “program-
ming tricks” but rather is based on good organization of information and good al-
gorithms. A programmer who has not mastered the basic principles of clear design
is not likely to write efficient programs. Conversely, concerns related to develop-
ment costs and maintainability should not be used as an excuse to justify inefficient
performance. Generality in design can and should be achieved without sacrificing
performance, but this can only be done if the designer understands how to measure
performance and does so as an integral part of the design and implementation pro-
cess. Most computer science curricula recognize that good programming skills be-
gin with a strong emphasis on fundamental software engineering principles. Then,
once a programmer has learned the principles of clear program design and imple-
mentation, the next step is to study the effects of data organization and algorithms
on program efficiency.
Approach: This book describes many techniques for representing data. These
techniques are presented within the context of the following principles:
1. Each data structure and each algorithm has costs and benefits. Practitioners
need a thorough understanding of how to assess costs and benefits to be able
to adapt to new design challenges. This requires an understanding of the
principles of algorithm analysis, and also an appreciation for the significant
effects of the physical medium employed (e.g., data stored on disk versus
main memory).
2. Related to costs and benefits is the notion of tradeoffs. For example, it is quite
common to reduce time requirements at the expense of an increase in space
requirements, or vice versa. Programmers face tradeoff issues regularly in all

xiii
xiv Preface

phases of software design and implementation, so the concept must become


deeply ingrained.
3. Programmers should know enough about common practice to avoid rein-
venting the wheel. Thus, programmers need to learn the commonly used
data structures, their related algorithms, and the most frequently encountered
design patterns found in programming.
4. Data structures follow needs. Programmers must learn to assess application
needs first, then find a data structure with matching capabilities. To do this
requires competence in Principles 1, 2, and 3.
As I have taught data structures through the years, I have found that design
issues have played an ever greater role in my courses. This can be traced through
the various editions of this textbook by the increasing coverage for design patterns
and generic interfaces. The first edition had no mention of design patterns. The
second edition had limited coverage of a few example patterns, and introduced
the dictionary ADT. With the third edition, there is explicit coverage of some
design patterns that are encountered when programming the basic data structures
and algorithms covered in the book.

Using the Book in Class: Data structures and algorithms textbooks tend to fall
into one of two categories: teaching texts or encyclopedias. Books that attempt to
do both usually fail at both. This book is intended as a teaching text. I believe it is
more important for a practitioner to understand the principles required to select or
design the data structure that will best solve some problem than it is to memorize a
lot of textbook implementations. Hence, I have designed this as a teaching text that
covers most standard data structures, but not all. A few data structures that are not
widely adopted are included to illustrate important principles. Some relatively new
data structures that should become widely used in the future are included.
Within an undergraduate program, this textbook is designed for use in either an
advanced lower division (sophomore or junior level) data structures course, or for
a senior level algorithms course. New material has been added in the third edition
to support its use in an algorithms course. Normally, this text would be used in a
course beyond the standard freshman level “CS2” course that often serves as the
initial introduction to data structures. Readers of this book should typically have
two semesters of the equivalent of programming experience, including at least some
exposure to Java. Readers who are already familiar with recursion will have an
advantage. Students of data structures will also benefit from having first completed
a good course in Discrete Mathematics. Nonetheless, Chapter 2 attempts to give
a reasonably complete survey of the prerequisite mathematical topics at the level
necessary to understand their use in this book. Readers may wish to refer back
to the appropriate sections as needed when encountering unfamiliar mathematical
material.
Preface xv

A sophomore-level class where students have only a little background in basic


data structures or analysis (that is, background equivalent to what would be had
from a traditional CS2 course) might cover Chapters 1-11 in detail, as well as se-
lected topics from Chapter 13. That is how I use the book for my own sophomore-
level class. Students with greater background might cover Chapter 1, skip most
of Chapter 2 except for reference, briefly cover Chapters 3 and 4, and then cover
chapters 5-12 in detail. Again, only certain topics from Chapter 13 might be cov-
ered, depending on the programming assignments selected by the instructor. A
senior-level algorithms course would focus on Chapters 11 and 14-17.
Chapter 13 is intended in part as a source for larger programming exercises.
I recommend that all students taking a data structures course be required to im-
plement some advanced tree structure, or another dynamic structure of comparable
difficulty such as the skip list or sparse matrix representations of Chapter 12. None
of these data structures are significantly more difficult to implement than the binary
search tree, and any of them should be within a student’s ability after completing
Chapter 5.
While I have attempted to arrange the presentation in an order that makes sense,
instructors should feel free to rearrange the topics as they see fit. The book has been
written so that once the reader has mastered Chapters 1-6, the remaining material
has relatively few dependencies. Clearly, external sorting depends on understand-
ing internal sorting and disk files. Section 6.2 on the UNION/FIND algorithm is
used in Kruskal’s Minimum-Cost Spanning Tree algorithm. Section 9.2 on self-
organizing lists mentions the buffer replacement schemes covered in Section 8.3.
Chapter 14 draws on examples from throughout the book. Section 17.2 relies on
knowledge of graphs. Otherwise, most topics depend only on material presented
earlier within the same chapter.
Most chapters end with a section entitled “Further Reading.” These sections
are not comprehensive lists of references on the topics presented. Rather, I include
books and articles that, in my opinion, may prove exceptionally informative or
entertaining to the reader. In some cases I include references to works that should
become familiar to any well-rounded computer scientist.

Use of Java: The programming examples are written in Java, but I do not wish to
discourage those unfamiliar with Java from reading this book. I have attempted to
make the examples as clear as possible while maintaining the advantages of Java.
Java is used here strictly as a tool to illustrate data structures concepts. In particular,
I make use of Java’s support for hiding implementation details, including features
such as classes, private class members, and interfaces. These features of the
language support the crucial concept of separating logical design, as embodied
in the abstract data type, from physical implementation as embodied in the data
structure.
xvi Preface

As with any programming language, Java has both advantages and disadvan-
tages. Java is a small language. There usually is only one language feature to do
something, and this has the happy tendency of encouraging a programmer toward
clarity when used correctly. In this respect, it is superior to C or C++ . Java serves
nicely for defining and using most traditional data structures such as lists and trees.
On the other hand, Java is quite poor when used to do file processing, being both
cumbersome and inefficient. It is also a poor language when fine control of memory
is required. As an example, applications requiring memory management, such as
those discussed in Section 12.3, are difficult to write in Java. Since I wish to stick
to a single language throughout the text, like any programmer I must take the bad
along with the good. The most important issue is to get the ideas across, whether
or not those ideas are natural to a particular language of discourse. Most program-
mers will use a variety of programming languages throughout their career, and the
concepts described in this book should prove useful in a variety of circumstances.
Inheritance, a key feature of object-oriented programming, is used sparingly
in the code examples. Inheritance is an important tool that helps programmers
avoid duplication, and thus minimize bugs. From a pedagogical standpoint, how-
ever, inheritance often makes code examples harder to understand since it tends to
spread the description for one logical unit among several classes. Thus, my class
definitions only use inheritance where inheritance is explicitly relevant to the point
illustrated (e.g., Section 5.3.1). This does not mean that a programmer should do
likewise. Avoiding code duplication and minimizing errors are important goals.
Treat the programming examples as illustrations of data structure principles, but do
not copy them directly into your own programs.
One painful decision I had to make was whether to use generics in the code
examples. Generics were not used in the first edition of this book. But in the years
since then, Java has matured and its use in computer science curricula has greatly
expanded. I now assume that readers of the text will be familiar with generic syntax.
Thus, generics are now used extensively in the code examples.
My implementations are meant to provide concrete illustrations of data struc-
ture principles, as an aid to the textual exposition. Code examples should not be
read or used in isolation from the associated text because the bulk of each exam-
ple’s documentation is contained in the text, not the code. The code complements
the text, not the other way around. They are not meant to be a series of commercial-
quality class implementations. If you are looking for a complete implementation
of a standard data structure for use in your own code, you would do well to do an
Internet search.
For instance, the code examples provide less parameter checking than is sound
programming practice, since including such checking would obscure rather than
illuminate the text. Some parameter checking and testing for other constraints
(e.g., whether a value is being removed from an empty container) is included in
Preface xvii

the form ofcalls to methods in class Assert. Method Assert.notFalse


takes a Boolean expression. If this expression evaluates to false, then a message
is printed and the program terminates immediately. Method Assert.notNull
takes a reference to class Object, and terminates the program if the value of
the reference is null. (To be precise, they throw an IllegalArgument-
Exception, which will terminate the program unless the programmer takes ac-
tion to handle the exception.) Terminating a program when a function receives a
bad parameter is generally considered undesirable in real programs, but is quite
adequate for understanding how a data structure is meant to operate. In real pro-
gramming applications, Java’s exception handling features should be used to deal
with input data errors. However, assertions provide a simpler mechanism for indi-
cating required conditions in a way that is both adequate for clarifying how a data
structure is meant to operate, and is easily modified into true exception handling.
I make a distinction in the text between “Java implementations” and “pseu-
docode.” Code labeled as a Java implementation has actually been compiled and
tested on one or more Java compilers. Pseudocode examples often conform closely
to Java syntax, but typically contain one or more lines of higher-level description.
Pseudocode is used where I perceived a greater pedagogical advantage to a simpler,
but less precise, description.

Exercises and Projects: Proper implementation and analysis of data structures


cannot be learned simply by reading a book. You must practice by implementing
real programs, constantly comparing different techniques to see what really works
best in a given situation.
One of the most important aspects of a course in data structures is that it is
where students really learn to program using pointers and dynamic memory al-
location, by implementing data structures such as linked lists and trees. It is often
where students truly learn recursion. In our curriculum, this is the first course where
students do significant design, because it often requires real data structures to mo-
tivate significant design exercises. Finally, the fundamental differences between
memory-based and disk-based data access cannot be appreciated without practical
programming experience. For all of these reasons, a data structures course cannot
succeed without a significant programming component. In our department, the data
structures course is one of the most difficult programming course in the curriculum.
Students should also work problems to develop their analytical abilities. I pro-
vide over 450 exercises and suggestions for programming projects. I urge readers
to take advantage of them.

Contacting the Author and Supplementary Materials: A book such as this


is sure to contain errors and have room for improvement. I welcome bug reports
and constructive criticism. I can be reached by electronic mail via the Internet at
shaffer@vt.edu. Alternatively, comments can be mailed to
xviii Preface

Cliff Shaffer
Department of Computer Science
Virginia Tech
Blacksburg, VA 24061
The electronic posting of this book, along with a set of lecture notes for use in
class can be obtained at
http://www.cs.vt.edu/˜shaffer/book.html.
The code examples used in the book are available at the same site. Online Web
pages for Virginia Tech’s sophomore-level data structures class can be found at
http://courses.cs.vt.edu/˜cs3114.
This book was typeset by the author using LATEX. The bibliography was pre-
pared using BIBTEX. The index was prepared using makeindex. The figures were
mostly drawn with Xfig. Figures 3.1 and 9.10 were partially created using Math-
ematica.
Acknowledgments: It takes a lot of help from a lot of people to make a book.
I wish to acknowledge a few of those who helped to make this book possible. I
apologize for the inevitable omissions.
Virginia Tech helped make this whole thing possible through sabbatical re-
search leave during Fall 1994, enabling me to get the project off the ground. My de-
partment heads during the time I have written the various editions of this book, Den-
nis Kafura and Jack Carroll, provided unwavering moral support for this project.
Mike Keenan, Lenny Heath, and Jeff Shaffer provided valuable input on early ver-
sions of the chapters. I also wish to thank Lenny Heath for many years of stimulat-
ing discussions about algorithms and analysis (and how to teach both to students).
Steve Edwards deserves special thanks for spending so much time helping me on
various redesigns of the C++ and Java code versions for the second and third edi-
tions, and many hours of discussion on the principles of program design. Thanks
to Layne Watson for his help with Mathematica, and to Bo Begole, Philip Isenhour,
Jeff Nielsen, and Craig Struble for much technical assistance. Thanks to Bill Mc-
Quain, Mark Abrams and Dennis Kafura for answering lots of silly questions about
C++ and Java.
I am truly indebted to the many reviewers of the various editions of this manu-
script. For the first edition these reviewers included J. David Bezek (University of
Evansville), Douglas Campbell (Brigham Young University), Karen Davis (Univer-
sity of Cincinnati), Vijay Kumar Garg (University of Texas – Austin), Jim Miller
(University of Kansas), Bruce Maxim (University of Michigan – Dearborn), Jeff
Parker (Agile Networks/Harvard), Dana Richards (George Mason University), Jack
Tan (University of Houston), and Lixin Tao (Concordia University). Without their
help, this book would contain many more technical errors and many fewer insights.
Preface xix

For the second edition, I wish to thank these reviewers: Gurdip Singh (Kansas
State University), Peter Allen (Columbia University), Robin Hill (University of
Wyoming), Norman Jacobson (University of California – Irvine), Ben Keller (East-
ern Michigan University), and Ken Bosworth (Idaho State University). In addition,
I wish to thank Neil Stewart and Frank J. Thesen for their comments and ideas for
improvement.
Third edition reviewers included Randall Lechlitner (University of Houstin,
Clear Lake) and Brian C. Hipp (York Technical College). I thank them for their
comments.
Prentice Hall was the original print publisher for the first and second editions.
Without the hard work of many people there, none of this would be possible. Au-
thors simply do not create printer-ready books on their own. Foremost thanks go to
Kate Hargett, Petra Rector, Laura Steele, and Alan Apt, my editors over the years.
My production editors, Irwin Zucker for the second edition, Kathleen Caren for
the original C++ version, and Ed DeFelippis for the Java version, kept everything
moving smoothly during that horrible rush at the end. Thanks to Bill Zobrist and
Bruce Gregory (I think) for getting me into this in the first place. Others at Prentice
Hall who helped me along the way include Truly Donovan, Linda Behrens, and
Phyllis Bregman. Thanks to Tracy Dunkelberger for her help in returning the copy-
right to me, thus enabling the electronic future of this work. I am sure I owe thanks
to many others at Prentice Hall for their help in ways that I am not even aware of.
I am thankful to Shelley Kronzek at Dover publications for her faith in taking
on the print publication of this third edition. Much expanded, with both Java and
C++ versions, and many inconsistencies corrected, I am confident that this is the
best edition yet. But none of us really knows whether students will prefer a free
online textbook or a low-cost, printed bound version. In the end, we believe that
the two formats will be mutually supporting by offering more choices. Production
editor James Miller and design manager Marie Zaczkiewicz have worked hard to
ensure that the production is of the highest quality.
I wish to express my appreciation to Hanan Samet for teaching me about data
structures. I learned much of the philosophy presented here from him as well,
though he is not responsible for any problems with the result. Thanks to my wife
Terry, for her love and support, and to my daughters Irena and Kate for pleasant
diversions from working too hard. Finally, and most importantly, to all of the data
structures students over the years who have taught me what is important and what
should be skipped in a data structures course, and the many new insights they have
provided. This book is dedicated to them.

Cliff Shaffer
Blacksburg, Virginia
PART I

Preliminaries

1
Discovering Diverse Content Through
Random Scribd Documents
Bishop Burnett, Baxter, Goodwin, Limborch, Celarius, Field, and many
others bear similar testimony.

when did it rise?


Since the New Testament knows nothing of infant baptism, and since
it was neither instituted by Christ, nor practiced by His Apostles, what
was its origin, and when did it come into use?
Tertullian is the first who mentions the custom, and he opposes it.
This was at the close of the second century, or about a. d. 200. His
opposition to it proves two things: First, that it was in occasional use,
at least. Second, that it was of recent origin, since had it been long used
some earlier record if it could be found. Neander, Ch. Hist., Vol. I., p.
311.
Bingham could find no earlier allusion to it than that of Tertullian,
though he believed it arose earlier. It must, therefore, as is generally
agreed, have had its origin about the beginning of the third century.
Curcellæus says: “The baptism of infants in the two first centuries
after Christ was altogether unknown; but in the third and fourth was
allowed by some few. In the fifth and following ages it was generally
received.” Inst. Christ. Religion, B. I., Ch. 12.
Salmasius says: “In the first two centuries no one was baptized, except,
being instructed in the faith and acquainted with the doctrines of
Christ, he was able to profess himself a believer.” Hist. Bapt. Suicer.
Thesaur., Vol. II., p. 1136.
Such testimony is conclusive, and quite sufficient, though much more
of a similar character might be added.
But observe: That when the baptism of children began, it was not that
of unconscious infants at all, as is now practiced, but, as Bunsen
declares, of “little growing children, from six to ten years old.” And he
asserts that Tertullian “does not say one word of new-born infants.”
Cyprian, an African bishop, at the close of the third century, urged the
baptism of infants proper, because of the saving efficacy of the
ordinance; and he is called the inventor, or father, of infant baptism.
Bunsen’s Hippol. and His Age, Vol. III., pp. 192-5.

why did it rise?


There is even less difficulty in tracing the cause than in finding the
origin of infant baptism. It originated in a perversion of Christian
doctrine, and was itself the perversion of a Christian ordinance.
All students of ecclesiastical history know that at an early period
corruptions perverted Christian faith and practice. Among these, one
of the earliest was that of an undue efficacy attributed to baptism. Its
sanctity was so exalted that it was believed to have power to wash away
sins, and cleanse the soul for heaven. By it the sick were supposed to be
prepared for death, and salvation made more certain by its efficacy.
Anxious parents therefore desired their dying children to be thus
prepared—“washed in the laver of regeneration,” as it was termed—
that they might be sure of salvation. And here came in that pernicious
error of “baptismal regeneration,” which gave rise to infant baptism,
and which has through all these ages clung with more or less
pertinacity to the clergy and laity of all churches which have practiced
it.
Salmasius says: “An opinion prevailed that no one could be saved
without being baptized; and for that reason the custom arose of
baptizing infants.” Epist. Jus. Pac. See Booth’s Pedo. Exam., Ch. III., Sec.
3.
Venema declares that “the ancients connected a regenerating power
with baptism.” He cites Justin Martyr, Irenæus, Clemens, Tertullian,
and Cyprian as holding that opinion. Eccl. Hist., Vol. 4, p. 3., Secs. 2, 3,
4.
Chrysostom, writing about a. d. 398, as cited by Suicerus, says, “It is
impossible without baptism to obtain the kingdom,” and as cited by
Wall he says: “If sudden death seize us before we are baptized, though
we have a thousand good qualities, there is nothing to be expected but
hell.” Suicer., Thesaur. Eccl., Vol. I., p. 3.
Waddington, in his Church History, says, in reference to the third
century: “A belief was gaining ground among the converts and was
inculcated among the heathen, that the act of baptism gave remission
of all sins committed previously.” Hist. of Church, Ch. II., p. 53.
Professor Fisher says: “Very early baptism was so far identified with
regeneration as to be designated by that term. This rite was considered
essential to salvation. A virtue was believed to reside in the baptismal
water itself.” Hist. Christ. Ch., p. 83.
Do its advocates and supporters hold the same view now? Do parents
and ministers still believe that the baptism of unconscious infants
secures, or makes more sure, their salvation? If not, why do they
practice it?
Professor Lange’s words are weighty, and should be carefully
pondered by Protestant defenders of this Papal emanation. He says:
“Would the Protestant Church fulfill and attain to its final destiny, the
baptism of new-born children must of necessity be abolished. It has
sunk down to a mere formality, without any meaning for the child.”
History of Protestantism, p. 34.
Many good people, familiar with infant baptism and surrounded by its
influences, have naturally learned to reverence it as of Divine
appointment, and some of them really believe it is taught or
sanctioned by the New Testament. But Baptists are right in rejecting it
as something utterly without foundation in the Word of God.

household baptisms
Much stress is laid by some of the advocates of infant baptism on that
fact that in the Acts of the Apostles several cases of household baptism
are mentioned. And it is asked with an air of assurance: “If entire
households were baptized, must there not have been children among
them? And were they not baptized also?” To this it is sufficient to reply,
that nothing is said of children, and we have no right to put into the
Scriptures what we do not find in them. All inference that such
households contained infants, and that such infants were baptized, is
the purest fiction in the world. If Christian institutions could be built
on so slight a foundation as that, we could bring in all the mummeries
of the Greek or the Roman Church, and all the ceremonies of the
Mosaic ritual.
One thing is certain: If in those households any children were
baptized, they were old enough to receive the Gospel and to believe on
Christ, and were thus suitable subjects for the ordinance, and for
church fellowship. For it is said, “They believed, and gladly received the
Word.” There are thousands of Baptist churches into whose fellowship
whole households have been baptized—parents and children and
perhaps others connected with them. But all were old enough to believe
and to make profession of their faith. So evidently it was in these
households.
The more prominent of these households are that of Lydia, mentioned
in Acts 16; that of the Philippian jailer, mentioned also in Acts 16; and
that of Stephanas, mentioned in 1 Corinthians 1. Now note what a few
distinguished Pedobaptist scholars say on these cases.
Doctor Neander says: “We cannot prove that the Apostles ordained
infant baptism; from those places where the baptism of a whole family
is mentioned, we can draw no such conclusion.” Planting and Training,
p. 162, N. Y. Ed., 1865.
Professor Jacobi says: “In none of these instances has it been proved
that there were little children among them.” Kitto’s Bib. Cyc., Art. Bap.
Doctor Meyer says: “That the baptism of children was not in use at
that time appears evident from 1 Cor. 7:14.” Comment. on Acts 16:15.
Doctor De Wette says: “This passage has been adduced in proof of
the apostolical authority of infant baptism: but there is no proof here
that any except adults were baptized.” Com. New Test., Acts 16:15.
Doctor Olshausen says: “There is altogether wanting any conclusive
proof-text for the baptism of infants in the age of the apostles.” Com.
on Acts 16:15.
Bishop Bloomfield says of the jailer: “It is taken for granted that his
family became Christians as well as himself.” Com. on Acts 16:15.
Calvin, Doddridge, Henry, and other commentators declare that in this
case the household all believed, and therefore were baptized and did
rejoice. MacKnight considers the case of the household of Stephanas as
giving no countenance to the baptism of infants. And with him agree
Guise, Hammond, Doddridge, and others.
As to the argument used by some, that baptism came in the place of
circumcision, it is too weak and puerile, too far-fetched and destitute
of reason, to claim the serious regard of intelligent and candid minds.

CHAPTER XIII

church government
A Christian church is a society with a corporate life, organized on some
definite plan, adapted to some definite purpose, which it proposes to
accomplish. It has, therefore, its officers and ordinances, its laws and
regulations, fitted to administer its government and carry out its
purposes. The question then arises, What is the true and proper form
of church organization and government? We do not care to inquire as
to the various and contradictory forms, as we see them about us in the
different denominations, but what was the organic form and
government of the first churches, planted by and molded under the
hands of Christ’s inspired Apostles.
There are three special and widely different forms of church
government which have gained prevalence in Christian communities
during past age, and which are still maintained with varied success,
each of which claims to have been the original primitive form:
1. The prelatical, in which the governing power resides in prelates, or
diocesan bishops, and the higher clergy; as in the Roman, Greek,
English, and most Oriental churches.
2. The presbyterian, in which the governing power resides in
assemblies, synods, presbyteries, and sessions; as in the Scottish Kirk,
the Lutheran, and the various Presbyterian churches.
3. The independent, in which the body is self-governing, each single
and local church administering its own government by the voice of the
majority of its members; as among Baptists, Congregationalists,
Independents, and some other bodies.
Now which of these modes of church life and administration is taught
in the New Testament, if either? or which best accords with the
constitution and government of the Apostolic churches?
Baptists hold that each separate, local church is an independent body,
governing itself according to the laws of Christ, as found in the New
Testament; that each such church is independent of all other churches,
and of all other persons, so far as administration is concerned, owing
comity and fellowship to all, but allegiance and submission to none.
The government is administered by the body of the members, where
no one possesses a preeminence of authority, but each enjoys an
equality of rights, and in which, in matters of opinion, the majority
decides.
That this style of church structure is according to the New Testament
appears evident from a study of the sacred records themselves. The
Apostles treated the churches as independent bodies. Their epistles
were addressed to the churches as such; they reported their doings to
them; enjoined upon them the duty of discipline; exhorted, instructed,
and reproved them as independent and responsible bodies. They
recognized the right of the churches to elect their own teachers and
officers, a primary and fundamental right, which, when conceded
supposes all other rights and powers necessary to a self-governing
community acting under Divinely given laws.
Neander, the distinguished historian, says of the first age: “The
churches were taught to govern themselves.” “The brethren chose their
own officers from among themselves.” “In respect to the election of
church officers, the ancient principle was still adhered to: that the
consent of the community was necessary to the validity of every such
election, and each one was at liberty to offer reasons against it.” Introd.
Coleman’s Prim. Christ’y, p. 19; Ch. Hist., Vol. I., p. 199; Plant. and
Train., p. 156.
Mosheim says of the first century: “In those primitive times, each
Christian Church was composed of the people, the presiding officers,
and the assistants, or deacons. These must be the component parts of
every society. The principal voice was that of the people, or of the whole
body of Christians.” “The assembled people, therefore, elected their
own rulers and teachers.” Of the second century, he adds: “One
president, or bishop, presides over each church. He was created by the
common suffrages of the people.” “During a great part of this century,
all the churches continued to be, as at first, independent of each other.
Each church was a kind of small, independent republic, governing
itself by its own laws, enacted, or at least sanctioned, by the people.”
Eccl. Hist., Cent. 1, Part 1, Ch. 2, Sec. 5, 6; Cent. 2, Ch. 2, Sec. 1, 2.
Coleman says: “These churches, wherever formed, became separate
and independent bodies, competent to appoint their own officers and
administer their own government without reference or subordination
to any control, authority or foreign power. No fact connected with the
history of the primitive church is more fully established or more
generally conceded.” Prim. Christ. Exemp., Ch. 4, Sec. 4, p. 95.
Archbishop Whately, Doctor Barrow, Doctor Burton, Doctor
Waddington—all of them Church of England Divines—fully agree with
this testimony, and confirm the evidence cited:
Geiseler, the historian, says, concerning early changes: “Country
churches, which had grown up around some city, seem, with their
bishops, to have been usually, in a certain degree, under the authority
of the mother church. With this exception, all the churches were alike
independent, though some were especially held in honor, on such
grounds as their Apostolic origin, or the importance of the city in
which they were situated.” Ch. Hist., Period 1, Div. 1, Ch. 3, Sec. 52.
Further discussion on this subject is not needed. The point is proved,
and the independent form of church government is manifestly
primitive and apostolic, as advocated and practiced by Baptists.

CHAPTER XIV

church officers
How many, and what are the Scriptural officers of a Christian church?
For a church, being a society, must have not only laws, but officers to
execute them. How many orders are there in the ministry? These are
questions which have at times greatly divided the Christian world.
Baptists assert that the officers of a church are two,—and of right, can
be no more,—pastor and deacons. In this opinion agree some other
denominations, while the various Episcopal sects insist that there
should be three sets—deacons, priests, and bishops, to which the
Church of England adds archbishops. Others add to this number
indefinitely; and the Romish Church carries the list up to ten or twelve,
ending with the pope. Now it is not so much what this church preaches
or practices, but on what basis were the primitive churches—the
churches of inspiration—organized. Our Lord did not live to shape,
and model, and put in order all things for the full equipment of His
people, that they might be thoroughly furnished unto all good works,
but He did give to His Apostles a spirit of wisdom by which they should
be able to do all this, and carry out His plans, in the organization of His
kingdom after He had left them. We assume that the first churches
were organized on the Divine plan, and seek to ascertain what that
plan was.
In the New Testament, the words bishop, presbyter, elder, are used to
designate church officers. They all, however, designate the same office,
and therefore officially mean the same thing; indeed, they are not
infrequently applied to the same individual. The bishop—called also
the presbyter, or elder—was the pastor, or overseer of the spiritual
flock, watching, guiding, and feeding it, as the shepherd does his
sheep. The deacons were chosen to attend to the temporal interests of
the church, as appears by the election of the seven, recorded in the
sixth chapter of Acts. This was done in order that the Apostles might
be free from the temporal cares, and thus able to give their attention
more exclusively to the spiritual welfare of the people. The word
deacon means a minister, a servant. It is sometimes applied to the
Apostles, and even to Christ himself, in the general sense as one who
“came, not to be ministered unto, but to minister, and to give His life a
ransom for many.” Some of the first deacons were also efficient
preachers of the Gospel, but their work as deacons pertained to other
services in the churches. While, therefore, the deacon is a church
officer, his office does not constitute an order in the ministry at all, its
functions belonging to temporal concerns, and not to a spiritual
service. The service usually performed by clerks, trustees, and the like,
it may be presumed, so far as such service was needed in the first
churches, was devolved on the deacons.
Pastors, by whatever name they may have been known, had the same
service, and were of the same grade, dignity, and authority. In the first
churches there were no high orders of clergy placed over lower grades,
and over the churches ruling with superior authority. All were equals
among equals, and all equally ministered to the churches. If in the
same church there might chance to be several to whom the titles
bishop, presbyter, or elder were applied, they were all of equal rank or
authority, though one might be selected to serve as the pastor of the
church, and devote himself to its local interests; while the others might
give themselves to more general missionary work.
Neander says: “The word presbyter, or elder, indicates rather the
dignity of the office, since presbyters among the Jews were usually aged
and venerable; while bishop, or episcopos, designated the nature of
their work as overseers, or pastors of the churches. The former title was
used by Jewish Christians as a name familiar in the synagogue; while
the latter was chiefly used by the Greek and other Gentile converts, as
more familiar and expressive to them.” “They were not designed to
exercise absolute authority, but to act as presiding officers and guides
of an ecclesiastical republic: to conduct all things, with the cooperation
of the communities, as their ministers and not as their masters.” Introd.
to Cole., Prim. Ch., p. 20; Ch. Hist., Vol. 1., p. 184; Plant. and Train., p.
147.
Mosheim says: “The rulers of the churches were denominated
sometimes presbyters, or elders, a designation borrowed from the Jews,
and indicative rather of the wisdom than the age of the persons, and
sometimes also bishops: for it is most manifest that both terms are
promiscuously used in the New Testament of one and the same class of
persons.” “In these primitive times, each Christian church was
composed of the people, the presiding officers, and the assistants, or
deacons. These must be the components of every society.” Eccl. Hist.,
Cent 1., p. 2; Ch. 2, Secs. 5, 8.
Gieseler asserts: “The new churches everywhere formed themselves
on the model of the mother church at Jerusalem. At the head of each
were the elders (presbyter, bishop), all officially of equal rank, though in
several instances a peculiar authority seems to have been conceded to
some one individual from personal considerations.” Ch. Hist., Part 1,
Div. 1, Ch. 2, Sec. 29.
Waddington declares: “It is also true that in the earliest government
of the first Christian society,—that of Jerusalem,—not the elders only,
but the ‘whole church,’ were associated with the Apostles; and it is even
certain that the terms bishop and elder, or presbyter, were in the first
instance and for a short period, sometimes used synonymously, and
indiscriminately applied to the same order in the ministry.” Hist.
Christ. Church, Ch. 2, Sec. 2.
Archbishop Usher says that “bishop and presbyter differed only in
degree, and not in order.” See Cole., Anc. Christ. Exemp., Ch. 8, Sec. 6.
Bishop Burnett says: “As for the notion of distinct offices of bishop
and presbyter, I confess it is not so clear to me.” Vindic. Ch. of Sects, p.
366.
Doctor Coleman says: “It is generally admitted by Episcopal writers
on this subject, that in the New Testament, and in the earliest
ecclesiastical writings, the terms bishops and presbyters, or elders, are
synonymous, and denote one and the same office.” “The office of
presbyter was undeniably identical with that of bishop, as has been
shown above.” “Only two orders of officers are known in the church
until the close of the second century. Those of the first are styled either
bishops or presbyters; of the second, deacons.” Anc. Christ. Exemp., Ch.
8, Sec. 6; Ch. 6, Sec. 5.
This author cites many of the early Christian Fathers who bore the
same testimony, among whom are Clement of Rome, Polycarp, Justin
Martyr, Irenæus, Jerome, Chrysostom, Theodoret, and others. Many
prelatical writers, besides these above quoted, frankly admit the same
facts.
The Apostle Paul, it is stated (Acts 20:17, 18), called together the elders
(presbyters) of the Ephesian Church. But in verse 28 he calls these
officers overseers (episcopos). Here the terms presbuteros and
episcopos were certainly used interchangeably.
Paul and Timothy, in their address to the Philippian Christians, specify
three classes as evidently constituting the entire body of disciples. They
say, “To all the saints in Christ Jesus, which are at Philippi, with the
bishops and deacons.” Saints, bishops, and deacons embraced the
whole church.
Timothy was instructed by Paul as to the qualifications of pastors to be
placed over the churches. (1 Tim. 3:1.) Particular directions are given as
to both bishops and deacons, but no mention is made of elders—
clearly because they were the same as bishops.
Titus is likewise enjoined to secure pastors for the church in Crete.
(Titus 1:5, 7.) These pastors are called elders in verse 5 and bishops in
verse 7.
Pastors and deacons, therefore, are two orders, and these officers
simply were known or needed in the Apostolic churches. In this, also,
the views held by Baptists are in harmony with the customs of the
churches in the first and purest age of Christian history.

CHAPTER XV

baptist history
It is sometimes asked: “When and where did the Baptists originate?
Who were their founders? What is their history?” These are questions
of interest; but a more important one would be: “Are they right? Is
their faith according to the teachings of the New Testament?” Many
things which are old are not true. Creeds and sects may boast a
venerable antiquity, while the Word of God utterly condemns them.
Any organization that cannot reasonably claim Christ for its founder
has small right to the name of a Christian church, no matter how old it
may be.
Baptists claim to be built on the foundation of the Apostles and
prophets, Jesus Christ Himself being the chief Corner-Stone. If this
claim be well founded, whether they have a written history of one
century or of twenty, matters little. Yet whatever of the past belongs to
any, it may be well to know. Any Baptist history constitutes one of the
most interesting chapters in the records of Christianity.
During the Apostolic age even, the doctrines of the Gospel became
corrupted, and its ordinances soon after. Both Jewish and Gentile
converts brought into the churches many of their old religious notions,
and incorporated them with the faith of Christ. These, together with
the many philosophical ideas of the times and the perversions to which
the truth is always exposed from the ignorance and selfishness of men,
very early turned the churches aside from the faith once delivered to
the saints. Still there were many who in simplicity and humility
maintained the doctrines and customs in their original purity. Those
churches which were strongest and most prosperous were most
exposed to corruption by alliances with the world.
When at length the period of martyrdom and persecution terminated;
when a nominal Christianity took possession of a throne, and Church
and State became united, then religion, in its prevailing forms, lost its
simplicity, its spirituality, and its power, and a temporal hierarchy took
the place of the church of Christ. This was the great apostasy of the
early times. But all the churches and all disciples did not follow in the
wake of this sad departure from the truth. Many congregations and
communities of true worshipers kept the doctrines of the Gospel, and
practiced its ordinances, nearly, or quite in their primitive purity. And
this they continued to do through all the ages of darkness and
corruption which followed. They were never identified with the Roman
or Greek churches; they never were in alliance with States; never
formed hierarchies. As independent congregations, or small
communities, with no other bond of union than a common faith,
fellowship, and sympathy, often obscure and unobtrusive, taking the
Word of God as their guide, they sought to realize the idea, not of a
temporal, but a spiritual kingdom in the Gospel dispensation.
These religious communities were by the dominant hierarchies called
sects, and stigmatized as heretics. As such they were traduced and
persecuted continually. And though they may have had their errors,
they were the best and purest defenders of the Christian faith, and the
truest representatives of the first disciples of Christ then existing. The
State churches were the heretics; while those so-called sects were the
true successors of the first Christians.
They were defamed and oppressed, calumniated and martyred because
they bore witness to the truth of God and testified against the errors
and vices of the so-called churches. History has never done them
justice, and perhaps never will; because history has been too much
written in the interest of their enemies, or from their standpoint.
Tortured and tormented by those who should have been their
defenders, crowns and miters alike pledged to their destruction, they
could do nothing but suffer. And this they nobly did as Christ’s faithful
witnesses. They were known by various names in different ages and in
different lands, but retained the same general characteristics.
In the first and second centuries, Messalians, Montanists, Euchites,
were terms which distinguished some of these sects.
In the third, fourth, and fifth centuries arose the Novatians. Increasing
with exceeding rapidity, they quite overspread the Roman empire, in
spite of the cruel and destructive persecutions which they suffered.
In the fourth century the Donatists appeared, as a new form of existing
sects, or a new phase of the old faith. They multiplied rapidly, spread
extensively, and long survived.
In the seventh century appeared the Paulicians, attracting much
attention, and calling down upon themselves the wrath of the Romish
Church. Still they increased greatly, notwithstanding their many
persecutions.
That these Christian communities should have been faultless could not
be supposed. But they were the best of the ages in which they lived,
and maintained the purest forms of Gospel truth and practice.
Without the advantage of organization and association, they differed
somewhat among themselves.
But in general they all professed to take the New Testament as the rule
of their faith and practice. They held to a spiritual church-
membership, and received only professedly regenerated persons to the
ordinances. Denying the orthodoxy of the Romish Church, they
rebaptized persons received from that body, and hence were called
Anabaptists. Infant baptism they rejected, according to Allix,
Mosheim, Robinson, and other historians. Baptism they administered
by immersion, as indeed did all Christians during those ages. Robinson
calls them “Trinitarian Baptists.” It is said that the Empress Theodora,
after having confiscated their property, caused to be cruelly put to
death no less than one hundred thousand Paulicians, for no other fault
or offense than their religious faith.
About the close of the tenth century appeared the Paterines;
substantially the same people, no doubt as had previously existed
under other names. They too rejected infant baptism, and protested
against the corruptions of the Romish Church; in consequence of
which they suffered long and severe persecution.
In the eleventh century, and the ages following, were the Waldenses,
Albigenses, Vaudois, Cathari, and Poor Men of Lyons. These were new
names, and names usually given by their enemies. They increased, even
under their persecutions, to a wonderful extent, and attracted the
notice, if not the sympathy, of all Europe.
It is not pretended that these ancient sects were known by the name as
Baptists; but in general they held the more prominent and distinctive
principles which have always characterized the Baptists; thus: 1. They
declared and defended the rights of faith and conscience and the
freedom of worship. 2. They denied the authority of popes and the
right of kings and States to interfere with the people in matters of
religion. 3. They rejected infant baptism. 4. They baptized by dipping.
5. They held the Bible to be the only rule and authority in concerns of
religious faith and practice. 6. They admitted to the churches none
except such as professed to be regenerated and godly persons.
Now it is conceded by all historians of note that such churches and
communities did exist, separate from and persecuted by, the prevailing
State churches and civil authorities during all the ages from the
Apostles to the Reformation.
When the Reformation under Luther and his coadjutors broke out,
these sects to a great extent fraternized with, and were lost in, the
multitude of the reformers. Such as continued their separate existence,
as the Waldenses of Piedmont, yielding to the influence of the
reformers, did from sympathy what the persecutions of the Papists had
never been able to compel them to do—abandon dipping for sprinkling
in baptism, adopted infant baptism, and took the general forms of
religious life, into which Pedobaptist Protestantism grew.

the welsh baptists


Few denominations have a better claim to antiquity than the Welsh
Baptists. They trace their descent directly from the Apostles and urge
in favor of their claim arguments which have never been confuted.
When Austin, the Romish monk and missionary, visited Wales, at the
close of the sixth century, he found a community of more than two
thousand Christians, quietly living in their mountain homes. They
were independent of the Romish See, and wholly rejected its authority.
Austin labored hard to convert them—that is, to bring them under the
Papal yoke; but entirely failed in the effort. Yielding things in general,
he reduced his demand upon them to three particulars: 1. That they
should observe Easter in due form, as ordered by the Church. 2. That
they should give Christendom, or baptism, to their children. 3. That
they should preach to the English the Word of God, as directed.[1]
These demands of Austin prove that they neither observed the Popish
ordinance of Easter, nor baptized their children. They, however,
rejected all his overtures, whereupon he left them with threats of war
and wretchedness. Not long after, Wales was invaded by the Saxons,
and many of these inoffensive Christians cruelly murdered, as was
believed, at the instigation of this bigoted zealot, the exacting Austin.
the dutch baptists
The Baptists of Holland have a history that reaches back to a very
remote period, if not to the Apostolic age, as some confidently assert.
And this antiquity is conceded by historians who have no sympathy
with their denominational sentiments.
Mosheim, in his Church History, says, “The true origin of that sect
which acquired the name Anabaptist is hid in the remote depths of
antiquity, and is consequently extremely difficult to be ascertained.”
Eccl. Hist., Vol. IV., p. 427, Mac. Ed., 1811. See Introd. Orchard’s Hist.
Bap., p. 17.
Zwingli, the Swiss Reformer, contemporary with Luther, declares:
“The institution of Anabaptism is no novelty but for thirteen hundred
years has caused great disturbance in the church.” Introd. Orchard’s
Hist. Bap., p. 17. Thirteen hundred years before his time would have
carried it back to within two centuries of the death of Christ.
Doctor Dermont, chaplain to the king of Holland, and Doctor Ypeij,
professor of theology at Groningen, a few years since received a royal
commission to prepare a history of the Reformed Dutch Church. That
history, prepared under royal sanction, and officially published,
contains the following manly and generous testimony to the antiquity
and orthodoxy of the Dutch Baptists. “We have now seen that the
Baptists, who were formerly called Anabaptists, and in later times
Mennonites, were the original Waldenses, and have long in the history
of the church received the honor of that origin. On this account, the
Baptists may be considered the only Christian community which has
stood since the Apostles, and as a Christian society, which has preserved
pure the doctrines of the Gospel through all ages.” Hist. Ref. Dutch Ch.,
Ed. Breda, 1819. See Ency. Relig. Knowledge, Art. Mennonites.
Mosheim says of the persecutions of this people in the sixteenth
century, “Vast numbers of these people, in nearly all the countries of
Europe, would rather perish miserably by drowning, hanging, burning,
or decapitation, than renounce the opinions they had embraced.” And
their innocency he vindicates thus: “It is indeed true that many
Anabaptists were put to death, not as being bad citizens, or injurious
members of civil society, but as being incurable heretics, who were
condemned by the old canon laws. For the error of adult baptism was
in that age looked upon as a horrible offense.” That was their only
crime. Eccl. Hist., Cent. 16, Sec. 3. Part 2, Ch. iii. Fuller’s Ch. Hist., B. 4.
This testimony is all the more welcome, because it comes from those
who have no ecclesiastical sympathies with Baptists, but who, in
fidelity to history, bear honest testimony to the truth which history
teaches. The circumstances under which their evidence was produced
give it additional force.
Cardinal Hossius, chairman of the council at Trent, says: “If the truth
of religion were to be judged of by the readiness and cheerfulness
which a man of any sect shows in suffering, then the opinions and
persuasions of no sect can be truer or surer, than those of the
Anabaptists; since there have been none, for these twelve hundred years
past, that have been more grievously punished.” Orchard’s Hist. Bap.,
Sec. 12, part 30, p. 364.
Many thousands of the Dutch Baptists, called Anabaptists, and
Mennonites, miserably perished by the hands of their cruel
persecutors, for no crime but their refusal to conform to established
churches.[2]

the english baptists


At what time the Baptists appeared in England in definite
denominational form, it is impossible to say. But from the twelfth to
the seventeenth century, many of them suffered cruel persecutions, and
death by burning, drowning, and beheading, besides many other, and
sometimes most inhuman tortures. And this they suffered both from
Papists and Protestants, condemned by both civil and ecclesiastical
tribunals, only because they persisted in worshiping God, according to
the dictates of their consciences, and because they would not submit
their religious faith and worship to the dictates of popes and princes.[3]
In 1538, royal edicts were issued against them, and several were burnt
at the stake in Smithfield.
Brande writes that: “In the year 1538, thirty-one Baptists, that fled
from England, were put to death at Delft, in Holland; the men were
beheaded, the women were drowned.” Hist. Reformers. See Benedict’s
Hist. Bap., p. 303. Neal’s Hist. Puritans, Vol. I., p. 138. Note, Vol. II, p.
355, Sup. What crime had they committed to merit such treatment as
this?
Bishop Latimer declares that, “The Baptists that were burnt in
different parts of the kingdom went to death intrepidly, and without
any fear, during the time of Henry VIII.” Lent Sermons. Neal’s Hist.
Purit., Vol. II, p. 356.
Under the rule of the Popish Mary, they suffered perhaps no more than
under that of the Protestant Elizabeth. During the reign of the latter a
congregation of Baptists was discovered in London, whereupon several
were banished, twenty-seven imprisoned, and two burnt at
Smithfield.[4]
Doctor Featley, one of their bitter enemies, wrote of them, in 1633:
“This sect, among others, hath so far presumed upon the patience of
the State, that it hath held weekly conventicles, rebaptizing hundreds
of men and women together in the twilight, in rivulets and in some
arms of the Thames, and elsewhere, dipping them all over head and
ears. It hath printed divers pamphlets in defense of their heresy; yea,
and challenged some of our preachers to disputation.” Eng. Bapt.
Jubilee Memor., Benedict’s Hist. Bapt., p. 304.
Bailey wrote, in 1639, that: “Under the shadow of independency they
have lifted up their heads, and increased their numbers above all sects
in the land. They have forty-six churches in and about London. They
are a people very fond of religious liberty, and very unwilling to be
brought under bondage of the judgment of others.” Benedict’s History,
p. 304.
The first book published in the English language on the subject of
baptism was translated from the Dutch, and bears date 1618. From this
time they multiplied rapidly through all parts of the kingdom. The first
regularly organized church among them, known as such in England,
dates from 1607, and was formed in London by a Mr. Smyth, previously
a clergyman of the Established Church.
In 1689, the Particular Baptists, so called, held a convention in London,
in which more than one hundred congregations were represented, and
which issued a confession of faith, still in use and highly esteemed.
The last Baptist martyr in England was Edward Wightman, of Burton
upon Trent, condemned by the Bishop of Coventry, and burnt at
Litchfield, April 11, 1612.[5]

american baptists
The history of American Baptists runs back a little more than two and
a quarter centuries. In this country, as elsewhere, they were cradled
amidst persecution, and nurtured by the hatred of their foes. This has
been their fortune in every age, and in every land.
Roger Williams, a distinguished and an honored name, was
identified with the rise of the denomination in America. He has been
called their founder, because he organized the first church, and was
intimately connected with their early history. Williams was born in
Wales, 1598, educated at Oxford, England, came to America in 1630,
and settled as minister of the Puritan church in Salem, Massachusetts.
Not long after, he adopted Baptist views of doctrine and church order,
on account of which he was banished by his fellow Puritans, and driven
out of Massachusetts, in the depths of a rigorous winter, in a new and
inhospitable country. Having wandered far and suffered much, finding
the savage Indians more generous and hospitable than his fellow
Christians, he finally reached and fixed his future home at what is now
Providence, R. I. Here, with a few associates of like faith, he founded a
new colony, calling both the city and the colony Providence, in
recognition of the Divine guidance and protection, which he had in so
remarkable a manner experienced.
In 1639, Mr. Williams received baptism from one of his associates,
there being no minister to perform that service. He in turn baptized
his associates, and a church was organized, of which he was chosen
pastor. He was also appointed first Governor of Rhode Island. Full
liberty was granted in matters of religion. Thus Roger Williams became
the first ruler, and Rhode Island the first State which ever gave entire
freedom to all persons to worship God, according to their own choice,
without dictation or interference from civil or ecclesiastical authorities.
On account of this unrestricted liberty many Baptists, as well as other
persecuted religionists from other colonies, and from Europe, collected
in considerable numbers at Providence, and spread through the colony.
It is a mistake to suppose that all the Baptist churches in America grew
out of the one which Roger Williams founded. It is even doubtful
whether any single church arose as an outgrowth of that. As
immigration increased, other churches grew up, having no connection
with that; and with considerable rapidity the sentiments of Baptists
spread into adjoining colonies, particularly west and south. For a long
time, however, they were sorely persecuted, especially in
Massachusetts and Connecticut; persecuted even by those who had
themselves fled from persecution in their native land, to find freedom
and refuge in these distant wilds.
In 1644, the present First Church in Newport, R. I., was organized. But
whether the present First Church in Providence was constituted before
this date is still a disputed point. Both claim priority. In 1656, the
Second Church, Newport, was formed. Then followed in order of time
the church in Swansea, Massachusetts, 1663; First, Boston, 1665; North
Kingstone, R. I., 1665; Seventh Day Church, Newport, 1671; South
Kingstone, R. I., 1680; Kittery, Me., 1682; Middletown, N. J., 1688;
Lower Dublin, Pa., 1689; Charleston, S. C., 1690; Philadelphia, Pa.,
1698; Welsh Tract, Del., 1701; Groton, Ct., 1705. Others, not mentioned,
arose within this period in these and other colonies. With the increase
of population, Baptists rapidly increased and widely spread over the
country.
Edward’s Tables gives the number of American Baptist Churches in
1768, as only 137.
Asplund’s Register for 1790, reported 872 churches, 722 ordained
ministers, with 64,975 members.
Benedict’s History states that in 1812, there were 2,633 churches, 2,143
ordained ministers, and 204,185 members.
Allen’s Register for 1836, puts them at 7,299 churches, 4.075 ordained
ministers, and 517,523 members.
The Baptist Year-Book gives the following figures:
Date Churches Ministers Members
1840 7,771 5,208 571,291
1860 12,279 7,773 1,016,134
1880 26,080 16,569 2,296,327
1890 33,588 21,175 3,070,047
1900 43,427 29,473 4,181,086
1910 49,045 33,909 5,266,369
1920 53,866 42,121 7,504,447
1930 53,888 49,907 8,915,785
The Year-Book gives the Sunday school statistics for 1930, as follows:
For the United States, schools, 46,132; total enrollment 5,143,056.
The figures given in all these cases are probably less than the actual
facts warrant, since full reports from associations, churches, and
schools can never be obtained.

other baptists
Besides the regular Baptist Brotherhood, there are in the United States
very many other and smaller denominations, which practice
immersion, but are not in fellowship with, or reckoned as a part of, the
great Baptist family.
The Seventh Day Baptists, so called on account of their observing
Saturday, or the seventh day of the week, as their Sabbath, on the
ground that the Jewish Sabbath was never abrogated. They are
estimated at about 7,000.
The Free Will Baptists, who take their name from their views as to the
freedom of the human will and practice open communion, number
about 66,000. In the North the Free Will Baptist churches have
generally united with the Northern Convention, and their membership
is reckoned with that of the regular Baptist body.
The Six Principle Baptists, so called because their doctrinal confession
is based on the six points mentioned in Hebrews 6:1, 2, are estimated at
about 300.
The Anti-Mission Baptists, or rather Primitive Baptists, found chiefly in
the Southwest, do not believe in missions, Sunday schools, or other
reform movements lest they should seem to interfere with the Divine
decrees. They are said to number 43,000.
The Disciples of Christ, sometimes called Campbellites, or Christians,
number about 1,200,000.
The Winebrennerians, or the General Eldership of the Churches of
God in North America, are estimated at about 30,000.
The Tunkers, or Dunkards, of all groups number about 126,000, and
the United Brethren, about 330,000.

baptists elsewhere
In North America, aside from the United States, but including the
provinces of British America, Central America, Mexico, and the West
Indies, Baptists numbered in 1930 about 249,809.
In Europe there were in 1930 about 1,639,656.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookfinal.com

You might also like