Instant Download (Ebook) Introduction to the Design & Analysis of Algorithms, Second Edition, International edition by Anany Levitin ISBN 9780321364135, 0321364139 PDF All Chapters
Instant Download (Ebook) Introduction to the Design & Analysis of Algorithms, Second Edition, International edition by Anany Levitin ISBN 9780321364135, 0321364139 PDF All Chapters
https://ebooknice.com/product/introduction-to-the-design-and-analysis-
of-algorithms-2nd-edition-2209914
https://ebooknice.com/product/introduction-to-the-design-and-analysis-
of-algorithms-11878072
https://ebooknice.com/product/biota-grow-2c-gather-2c-cook-6661374
https://ebooknice.com/product/introduction-to-the-design-and-analysis-
of-algorithms-21354940
(Ebook) Introduction to the design and analysis of algorithms by
Levitin A. ISBN 9780132316811, 0132316811
https://ebooknice.com/product/introduction-to-the-design-and-analysis-
of-algorithms-2597624
https://ebooknice.com/product/matematik-5000-kurs-2c-larobok-23848312
https://ebooknice.com/product/cambridge-igcse-and-o-level-history-
workbook-2c-depth-study-the-united-states-1919-41-2nd-edition-53538044
https://ebooknice.com/product/sat-ii-success-
math-1c-and-2c-2002-peterson-s-sat-ii-success-1722018
(Ebook) Master SAT II Math 1c and 2c 4th ed (Arco Master the SAT
Subject Test: Math Levels 1 & 2) by Arco ISBN 9780768923049,
0768923042
https://ebooknice.com/product/master-sat-ii-math-1c-and-2c-4th-ed-
arco-master-the-sat-subject-test-math-levels-1-2-2326094
Introduction to the Design Analysis of Algorithms Second
Edition International edition Anany Levitin Digital Instant
Download
Author(s): Anany Levitin
ISBN(s): 9780321364135, 0321364139
Edition: Second edition, International edition
File Details: PDF, 19.14 MB
Year: 2007
Language: english
Introduction to The Design &
~~ I_ND EDIIIQN ~
Analysis of Algorithms
*
Introduction to The Design &
~
Anany Levitin
Villanova University
Access the latest information about Addison-Wesley titles from our World Wide Web site:
http://www.aw-bc.com/cornputing
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 Addison-
Wesley was aware of a trademark claim, the designations have been printed in initial caps
or all caps.
If you purchased this book within the United States or Canada you should be aware that
it has been wrongfully imported without the approval of the Publisher or the Author.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval
system, or transmitted, in any form or by any means, electronic, mechanical, photocopying,
recording, or otherwise, without the prior written permission of the publisher. Printed in
the United States of America.
ISBN 0-321-36413-9
3 4 5 6 7 8 9 10-DOH-09 08 07
Brief Contents
Preface xvii
1 Introduction 1
2 Fundamentals of the Analysis of Algorithm Efficiency 41
3 Brute Force 97
4 Divide-and-Conquer 123
5 Decrease-and-Conquer 157
6 Transform-and-Conquer 197
1 Space and Time Tradeoffs 249
8 Dynamic Programming 279
9 Greedy Technique 307
1 0 Iterative Improvement 335
11 limitations of Algorithm Power 379
12 Coping with the Limitations of Algorithm Power 415
Epilogue 465
APPENDIX A
Useful Formulas for the Analysis of Algorithms 469
APPENDIX B
Short Tutorial on Recurrence Relations 473
Bibliography 487
Hints to Exercises 497
Index 541
v
r.
I;
I!
Contents
Preface xvii
1 Introduction 1
1.1 What is an Algorithm? 3
Exercises 1.1 8
1.2 Fundamentals of Algorithmic Problem Solving 9
Understanding the Problem 9
Ascertaining the Capabilities of a Computational Device 11
Choosing between Exact and Approximate Problem Solving 11
Deciding on Appropriate Data Structures 12
Algorithm Design Techniques 12
Methods of Specifying an Algorithm 12
Proving an Algorithm's Correctness 13
Analyzing an Algorithm 14
Coding an Algorithm 15
Exercises 1.2 17
vii
---~----·-·
Ijli
;!'
viii Contents
rll
!:! 1.4 Fundamental Data Structures 26
II:., Linear Data Structures 26
il Graphs 28
,.'II 32
I! Trees
Sets and Dictionaries 36
1:1 38
Exercises 1.4
Summary 39
f:i
I'-,,!
i!i 2.1 Analysis Framework 42
if! Measuring an Input's Size 43
li1 Units for Measuring Running Time 44
Orders of Growth 45
Worst-Case. Best-Case, and Average-Case Efficiencies 47
III Recapitulation of the Analysis Framework 50
Exercises 2.1 50
I
! 2.2 Asymptotic Notations and Basic Efficiency Classes 52
'
' Informal Introduction 52
a-notation 53
0-notation 54
e-notation 55
Useful Property Involving the Asymptotic Notations 56
Using Limits for Comparing Orders of Growth 57
Basic Efficiency Classes 58
Exercises 2.2 59
3 Brute Force 97
3.1 Selection Sort and Bubble Sort 98
Selection Sort 98
Bubble Sort 100
Exercises 3.1 102
4 Divide-and-Conquer 123
4.1 Mergesort 125
Exercises 4.1 128
.,
Iii
iii
•i
5 Decrease-and-Conquer 157
I! 160
:l'I;i 5.1 Insertion Sort
Exercises 5.1 163
l!i
'I 5.2 Depth-First Search and Breadth-First Search 164
Depth-First Search 165
',1
Breadth-First Search 167
·:
!I
Exercises 5.2 170
!'I
5.3 Topological Sorting 172
II
j, Exercises 5.3 176
II
!I 5.4 Algorithms for Generating Combinatorial Objects 177
il
,,!i Generating Permutations 178
i! Generating Subsets 180
,,
lr
Exercises 5.4 181
f.!
lr'I 5.5 Decrease-by-a-Constant-Factor Algorithms 183
Fake-Coin Problem 183
Multiplication a Ia Russe 184
Josephus Problem 185
Exercises 5.5 187
6 Transform-and-Conquer 197
xiv Contents
Epilogue 465
APPENDIX A
Useful formulas for the Analysis of Algorithms 469
Properties of Logarithms 469
Combinatorics 469
Important Summation Formulas 470
Sum Manipulation Rules 470
Approximation of a Sum by a Definite Integral 471
Floor and Ceiling Formulas 471
Miscellaneous 471
APPENDIX 18
Short Tutorial on Recurrence Relations 473
Sequences and Recurrence Relations 473
Methods for Solving Recurrence Relations 474
Common Recurrence Types in Algorithm Analysis 479
Bibliography 487
Index 541
r
I
Preface
A lgorithms play the central role in both the science and practice of computing.
Recognition of this fact has Jed to the appearance of a considerable number
of textbooks on the subject. By and large, they follow one of two alternatives
in presenting algorithms. One classifies algorithms according to a problem type.
Such a book would have separate chapters on algorithms for sorting, searching,
graphs, and so on. The advantage of this approach is that it allows an immediate
comparison of, say, the efficiency of different algorithms for the same problem.
The drawback of this approach is that it emphasizes problem types at the expense
of algorithm design techniques.
The second alternative organizes the presentation around algorithm design
techniques. In this organization, algorithms from different areas of computing are
grouped together if they have the same design approach. I share the belief of many
(e.g., [BaY95]) that this organization is more appropriate for a basic course on the
design and analysis of algorithms. There are three principal reasons for empha-
sis on algorithm design techniques. First, these techniques provide a student with
tools for designing algorithms for new problems. This makes learning algorithm
design techniques a very valuable endeavor from the practical standpoint. Second,
they seek to classify multitudes of known algorithms according to an underlying
design idea. Learning to see such commonality among algorithms from different
application areas should be a major goal of computer science education. After
all, every science considers classification of its principal subject as a major if not
the central point of its discipline. Third, in my opinion, algorithm design tech-
niques have considerable utility as general problem solving strategies, applicable
to problems beyond computing.
xvii
xvm Preface
L
Preface xix
course on the design and analysis of algorithms is uniquely suitable for this task
because it can offer a student specific strategies for solving problems.
I am not proposing that a course on the design and analysis of algorithms
should become a course on general problem solving. But I do believe that the
unique opportunity provided by studying the design and analysis of algorithms
should not be missed. Toward this goal, the book includes applications to puzzles
and puzzle-like games. Although using puzzles in teaching algorithms is certainly
not a new idea, the book tries to do so systematically by going well beyond a few
standard examples.
Textbook Pedagogy
My goal was to write a text that would not trivialize the subject but would still be
readable by most students on their own. Here are some of the things done toward
this objective.
" Sharing the opinion of George Forsythe expressed in the epigraph, I have
sought to stress major ideas underlying the design and analysis of algorithms.
In choosing specific algorithms to illustrate these ideas, I limited the number
of covered algorithms to those that most clearly demonstrate an underlying
design technique or analysis method. Fortunately, most classic algorithms
satisfy this criterion.
" In Chapter 2, which is devoted to efficiency analysis, the methods used for
analyzing nonrecursive algorithms are separated from those typically used for
analyzing recursive algorithms. The chapter also includes sections devoted to
empirical analysis and algorithm visualization.
" The narrative is systematically interrupted by questions to the reader. Some
of them are asked rhetorically, in anticipation of a concern or doubt, and are
answered immediately. The goal of the others is to prevent the reader from
drifting through the text without a satisfactory level of comprehension.
" Each chapter ends with a summary recapping the most important concepts
and results discussed in the chapter.
The book contains about 700 exercises. Some of them are drills; others make
important points about the material covered in the body of the text or intro-
duce algorithms not covered there at all. A few exercises take advantage of
Internet resources. More difficult problems-there are not many of them-are
marked with a special symbol in the Instructor's Manual. (Because designat-
ing problems as difficult may discourage some students from trying to tackle
them, problems are not marked in the book itself.) Puzzles, games, and puzzle-
like questions are marked in the exercises with a special icon.
" The book provides hints to all the exercises. Detailed solutions, except for
programming projects, are provided in the Instructor's Manual, available
r
XX Preface
Prerequisites
The book assumes that a reader has gone through an introductory programming
course and a standard course on discrete structures. With such a background,
he or she should be able to handle the book's material without undue difficulty.
Still, fundamental data structures, necessary summation formulas, and recurrence
relations are reviewed in Section 1.4, Appendix A, and Appendix B, respectively.
Preface xxi
Calculus is used in only three sections (Sections 2.2, 11.4, and 12.4) and to a very
limited degree; if students lack calculus as an assured part of their background,
the portions of these three sections that involve calculus can be omitted without
hindering their understanding of the rest of the material.
1 Introduction 1.1-1.3
2,3 Analysis framework; 0, 8, n notations 2.1,2.2
4 Mathematical analysis of nonrecursive algorithms 2.3
5,6 Mathematical analysis of recursive algorithms 2.4, 2.5 (+ App. B)
7 Brute-force algorithms 3.1, 3.2 (+ 3.3)
8 Exhaustive search 3.4
9-10 Divide-and-conquer: mergesort, quicksort, binary 4.1-4.3
search
11 Other divide-and-conquer examples 4.4 or 4.5 or 4.6
12-14 Decrease-by-one: insertion sort, DFS and BFS, 5.1-5.3
topological sorting
15 Decrease-by-a-constant-factor algorithms 5.5
16 Variable-size-decrease algorithms 5.6
17-19 Instance simplification: presorting, Gaussian 6.1-6.3
elimination, balanced search trees
20 Representation change: heaps and heapsort or 6.4 or
Horner's rule and binary exponentiation 6.5
21 Problem reduction 6.6
22-24 Space-time tradeoffs: string matching, hashing, 7.2-7.4
B-trees
25-27 Dynamic programming algorithms 3 from 8.1-8.4
28-30 Greedy algorithms: Prim's, Kruskal's, Dijkstra's, 9.1-9.4
Huffman's
xxii Preface
Acknowledgments
I would like to express my gratitude to the many people who have shared with
me their own and their students' opinions about the first edition and suggested
improvements and corrections. I have especially benefitted from the comments
by Eric Bach (University of Wisconsin), Stephen Bique (University of Alaska-
Fairbanks), Walter Hower (Albstadt-Sigmaringen University), Dan Joyce (Vil-
lanova University), Steven Lindell (Haverford College), and Mary-Angela Pa-
palaskari (Villanova University).
My thanks also go to Edward L. Bosworth (Columbus State University),
Philip Dorin (Loyola Marymount University), William Ford (University of the
Pacific), Jonathan Goldstine (Penn State University), Chin-Cheng Hung (South-
ern Polytechnic State University), and Brian Rosmaita (Hamilton College )-the
reviewers of the chapter on iterative-improvement algorithms-for supporting the
inclusion of this chapter in the new edition and for their ideas about presenting
these important algorithms.
In addition, I would like to convey my appreciation to the following review-
ers: David Avis (McGill University), Gordon Beavers (University of Arkansas),
Dinesh Mehta (Colorado School of Mines), Feridoon Moinian (Cameron Uni-
versity), Stephan Olariu (Old Dominion University), Stanley Selkow (WPI), Jerry
Trahan (Louisiana State University), and Yang Wang (Missouri State University).
I gratefully acknowledge the help I have received from my former student,
Rakhi Gandhi, whose assistance has certainly decreased the number of typos and
errors in the book.
I appreciate the contributions of all the reviewers of the first edition: Si-
mon Berkovich (George Washington University), Richard Borie (University of
Alabama), Douglas M. Campbell (Brigham Young University), Bin Cong (Cal-
ifornia State University, Fullerton), Steve Homer (Boston University), Roland
Htibscher (Auburn University), Sukhamay Kundu (Louisiana State University),
Sheau-Dong Lang (University of Central Florida), John C. Lusth (University of
Arkansas), John F. Meyer (University of Michigan), Steven R. Seidel (Michigan
Preface xxiii
Anany Levitin
[email protected]
December 2005
Introduction toThe Design &
fiND EDFFIC>N .
Analysis of Algorithms
i
,I
:·!
:iJ
II.I
iil!
:i!
I'
il
[i
1
Introduction
Two ideas lie gleaming on the jeweler's velvet. The first is the calculus,
the second, the algorithm. The calculus and the rich body of mathematical
analysis to which it gave rise made modern science possible; but it has been
the algorithm that has rnade possible the modern world.
-David Berlinski, The Advent of the Algorithm, 2000
1
.
w i!
'
.
2 Introduction
I' I
the other hand, this required precision has an important educational advantage.
Donald Knuth, one of the most prominent computer scientists in the history of
algorithmics, put it as follows:
'10
1
!J
t
1.1 What is an Algorithm? 3
problem
1
algorithm
" The range of inputs for which an algorithm works has to be specified carefully.
,. The same algorithm can be represented in several different ways.
" Several algorithms for solving the same problem may exist.
II! Algorithms for the same problem can be based on very different ideas and
can solve the problem with dramatically different speeds.
Recall that the greatest common divisor of two nonnegative, not -both-zero
integers m and n, denoted gcd(m, n), is defined as the largest integer that divides
both m and n evenly, i.e., with a remainder of zero. Euclid of Alexandria (third
century B.C.) outlined an algorithm for solving this problem in one of the volumes
of his Elements, most famous for its systematic exposition of geometry. In modern
terms, Euclid's algorithm is based on applying repeatedly the equality
gcd(m, n) = gcd(n, m mod n)
(where m mod n is the remainder of the division of m by n) until m mod n is equal
to 0; since gcd(m, 0) = m (why?), the last value of m is also the greatest common
divisor of the initial m and n.
For example, gcd(60, 24) can be computed as follows:
gcd(60, 24) = gcd(24, 12) = gcd(12, 0) = 12.
(If you are not impressed by this algorithm, try finding the greatest common divisor
of larger numbers such as those in Problem 5 of Exercises 1.1.)
Here is a more structured description of this algorithm:
Euclid's algorithm for computing gcd(m, n)
Step 1 If n = 0, return the value of m as the answer and stop; otherwise,
proceed to Step 2.
Step 2 Divide m by n and assign the value of the remainder to r.
Step 3 Assign the value of n tom and the value of r ton. Go to Step 1.
Alternatively, we can express the same algorithm in a pseudocode:
ALGORITHM Euclid(m, n)
//Computes gcd(m, n) by Euclid's algorithm
!!Input: Two nonnegative, not -both-zero integers m and n
//Output: Greatest common divisor of m and n
while n oJ 0 do
r +-m modn
m +-n
n +---- r
return m
each iteration and it cannot become negative. Indeed, the new value of n on the
next iteration ism mod n, which is always smaller than n. Hence, the value of the
second number in the pair eventually becomes 0, and the algorithm stops.
Just as with many other problems, there are several algorithms for computing
the greatest common divisor. Let us look at the other two methods for this prob-
lem. The first is simply based on the definition of the greatest common divisor of
m and n as the largest integer that divides both numbers evenly. Obviously, such
a common divisor cannot be greater than the smaller of these numbers, which we
will denote by t = min{m, n ). So we can start by checking whether t divides both
m and n: if it does, t is the answer; if it does not, we simply decrease t by 1 and
try again. (How do we know that the process will eventually stop?) For example,
for numbers 60 and 24, the algorithm will try first 24, then 23, and so on until it
reaches 12, where it stops.
Note that unlike Euclid's algorithm, this algorithm, in the form presented,
does not work correctly when one of its input numbers is zero. This example
illustrates why it is so important to specify the range of an algorithm's inputs
explicitly and carefully.
The third procedure for finding the greatest common divisor should be famil-
iar to you from middle school.
Nostalgia for the days when we learned this method should not prevent us
from noting that the last procedure is much more complex and slower than Euclid's
algorithm. (We will discuss methods for finding and comparing running times of
algorithms in the next chapter.) In addition to inferior efficiency, the middle-school
procedure does not qualify, in the form presented, as a legitimate algorithm. Why?
Because the prime factorization steps are not defined unambiguously: they require
a list of prime numbers, and I strongly suspect that your middle-school teacher
did not explain how to obtain such a list. You undoubtedly agree that this is not
a matter of unnecessary nitpicking. Unless this issue is resolved, we cannot, say,
write a program implementing this procedure. (Incidentally, Step 3 is also not
defined clearly enough. Its ambiguity is much easier to rectify than that of the
factorization steps, however. How would you find common elements in two sorted
lists?)
So let us introduce a simple algorithm for generating consecutive primes
not exceeding any given integer n. It was probably invented in ancient Greece
and is known as the sieve of Eratosthenes (ca. 200 B.C.). The algorithm starts by
initializing a list of prime candidates with consecutive integers from 2 ton. Then,
on the first iteration of the algorithm, it eliminates from the list all multiples of
2, i.e., 4, 6, and so on. Then it moves to the next item on the list, which is 3,
and eliminates its multiples. (In this straightforward version, there is an overhead
because some numbers, such as 6, are eliminated more than once.) No pass for
number 4 is needed: since 4 itself and all its multiples are also multiples of 2, they
were already eliminated on a previous pass. (By similar reasoning, we need not
consider multiples of any eliminated number.) The next remaining number on the
list, which is used on the third pass, is 5. The algorithm continues in this fashion
until no more numbers can be eliminated from the list. The remaining integers of
the list are the primes needed.
As an example, consider the application of the algorithm to finding the list of
primes not exceeding n = 25:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
2 3 5 7 9 11 13 15 17 19 21 23 25
2 3 5 7 11 13 17 19 23 25
2 3 5 7 11 13 17 19 23
For this example, no more passes are needed because they would eliminate num-
bers already eliminated on previous iterations of the algorithm. The remaining
numbers on the list are the consecutive primes less than or equal to 25.
In general, what is the largest number p whose multiples can still remain on
the list? Before we answer this question, let us first note that if p is a number
whose multiples are being eliminated on the current pass, then the first multiple
we should consider is p · p because all its smaller multiples 2p, ... , (p- l)p have
been eliminated on earlier passes through the list. This observation helps to avoid
1.1 What is an Algorithm? 7
eliminating the same number more than once. Obviously, p · p should not be
greater than n, and therefore p cannot exceed ,jn rounded down (denoted ,jn l J
using the so-called floor function). We assume in the following pseudocode that
l J;
there is a function available for computing ,jn alternatively, we could check
the inequality p · p S n as the loop continuation condition there.
ALGORITHM Sieve(n)
//Implements the sieve of Eratosthenes
//Input: An integer n ": 2
//Output: Array L of all prime numbers less than or equal ton
for p-<-- 2 ton do A[p]-<- p
l
for p -<-- 2 to ,Jnj do //see note before pseudocode
if A[p] i' 0 II p hasn't been eliminated on previous passes
j-<-P*P
while j S n do
A[j] -<-- 0 //mark element as eliminated
j-<-j+p
//copy the remaining elements of A to array L of the primes
i-<--0
forp-<-2tondo
ifA[p]i'O
L[i]+- A[p]
i-<-i+1
return L
-----Exercises 1.1
1. Do some research on al-Khorezmi (also al-Khwarizmi), the man from whose
name the word "algorithm" is derived. 1n particular, you should learn what
the origins of the words "algorithm)' and "algebra" have in common.
2. Given that the official purpose of the U.S. patent system is the promotion
of the "useful arts," do you think algorithms are patentable in this country?
Should they be?
3. a. Write down driving directions for going from your school to your home
with the precision required by an algorithm.
b. Write down a recipe for cooking your favorite dish with the precision
required by an algorithm.
4. Design an algorithm for computing LftJ for any positive integer n. Besides
assignment and comparison, your algorithm may only use the four basic
arithmetical operations.
:I
5. a. Find gcd(31415, 14142) by applying Euclid's algorithm.
b. Estimate how many times faster it will be to find gcd(31415, 14142) by
Euclid's algorithm compared with the algorithm based on checking con-
secutive integers from min{m, n) down to gcd(m, n).
6. Prove the equality gcd(m, n) = gcd(n, m mod n) for every pair of positive
integers m and n.
7. What does Euclid's algorithm do for a pair of numbers in which the first
number is smaller than the second one? What is the largest number of times
this can happen during the algorithm's execution on such an input?
8. a. What is the smallest number of divisions made by Euclid's algorithm
among all inputs 1 ::= m, n ::= 10?
b. What is the largest number of divisions made by Euclid's algorithm among
all inputs 1 ::= m, n ::= 10?
9. a. Euclid's algorithm, as presented in Euclid's treatise, uses subtractions
rather than integer divisions. Write a pseudocode for this version of Eu-
clid's algorithm.
b. Euclid's game (see [Bog]) starts with two unequal positive numbers on the
board. Two players move in turn. On each move, a player has to write on
the board a positive number equal to the difference oftwo numbers already
on the board; this number must be new, i.e., different from all the numbers
already on the board. The player who cannot move loses the game. Should
you choose to move first or second in this game?
10. The extended Euclid's algorithm determines not only the greatest common
divisor d of two positive integers m and n but also integers (not necessarily
positive) x andy, such that mx + ny =d.
1.2 Fundamentals of Algorithmic Problem Solving 9
Decide on:
computational means,
exact vs. approximate solving,
data structure(s),
algorithm design technique
Design an algorithm
Prove correctness
Using a natural language has an obvious appeal; however, the inherent ambi-
guity of any natural language makes a succinct and clear description of algorithms
surprisingly difficult. Nevertheless, being able to do this is an important skill that
you should strive to develop in the process of learning algorithms.
A pseudocode is a mixture of a natural language and programming language-
like constructs. A pseudocode is usually more precise than a natural language, and
its usage often yields more succinct algorithm descriptions. Surprisingly, computer
scientists have never agreed on a single form of pseudocode, leaving textbook
authors to design their own "dialects." Fortunately, these dialects are so close to
each other that anyone familiar with a modern programming language should be
able to understand them all.
This book's dialect was selected to cause minimal difficulty for a reader. For
the sake of simplicity, we omit declarations of variables and use indentation to
show the scope of such statements as for, if, and while. As you saw in the previous
section, we use an arrow <-- for the assignment operation and two slashes I I for
comments.
In the earlier days of computing, the dominant vehicle for specifying algo-
rithms was a flowchart, a method of expressing an algorithm by a collection of
connected geometric shapes containing descriptions of the algorithm's steps. This
representation technique has proved to be inconvenient for all but very simple
algorithms; nowadays, it can be found only in old algorithm books.
The state of the art of computing has not yet reached a point where an
algorithm's description-whether in a natural language or a pseudocode-can be
fed into an electronic computer directly. Instead, it needs to be converted into a
computer program written in a particular computer language. We can look at such
a program as yet another way of specifying the algorithm, although it is preferable
to consider it as the algorithm's implementation.
14 Introduction
show that an algorithm is incorrect, you need just one instance of its input for
which the algorithm fails. If the algorithm is found to be incorrect, you need to ei-
ther redesign it under the same decisions regarding the data structures, the design
technique, and so on, or, in a more dramatic reversal, to reconsider one or more
of those decisions (see Figure 1.2).
The notion of correctness for approximation algorithms is less straightforward
than it is for exact algorithms. For an approximation algorithm, we usually would
like to be able to show that the error produced by the algorithm does not exceed
a predefined limit. You can find examples of such investigations in Chapter 12.
Analyzing an Algorithm
We usually want our algorithms to possess several qualities. After correctness, by
far the most important is efficiency. In fact, there are two kinds of algorithm effi-
ciency: time efficiency and space efficiency. Time ~fficiency indicates how fast the
algorithm runs; space efficiency indicates how much extra memory the algorithm
needs. A general framework and specific techniques for analyzing an algorithm's
efficiency appear in Chapter 2.
Another desirable characteristic of an algorithm is simplicity. Unlike effi-
ciency, which can be precisely defined and investigated with mathematical rigor,
simplicity, like beauty, is to a considerable degree in the eye of the beholder. For
example, most people would agree that Euclid's algorithm is simpler than the
middle-school procedure for computing gcd(m, n), but it is not clear whether Eu-
clid's algorithm is simpler than the consecutive integer checking algorithm. Still,
simplicity is an important algorithm characteristic to strive for. Why? Because sim-
pler algorithms are easier to understand and easier to program; consequently, the
resulting programs usually contain fewer bugs. There is also the undeniable aes-
thetic appeal of simplicity. Sometimes simpler algorithms are also more efficient
than more complicated alternatives. Unfortunately, it is not always true, in which
case a judicious compromise needs to be made.
Yet another desirable characteristic of an algorithm is generality. There are,
in fact, two issues here: generality of the problem the algorithm solves and the
range of inputs it accepts. On the first issue, note that it is sometimes easier to
design an algorithm for a problem posed in more general terms. Consider, for
example, the problem of determining whether two integers are relatively prime,
i.e., whether their only common divisor is equal to 1. It is easier to design an
algorithm for a more general problem of computing the greatest common divisor
of two integers and, to solve the former problem, check whether the gcd is 1 or
not. There are situations, however, where designing a more general algorithm is
unnecessary or difficult or even impossible. For example, it is unnecessary to sort
a list of n numbers to find its median, which is its rn/21 th smallest element. To give
another example, the standard formula for roots of a quadratic equation cannot
be generalized to handle polynomials of arbitrary degrees.
1.2 Fundamentals of Algorithmic Problem Solving 15
Coding an Algorithm
Most algorithms are destined to be ultimately implemented as computer pro-
grams. Programming an algorithm presents both a peril and an opportunity. The
peril lies in the possibility of making the transition from an algorithm to a pro-
gram either incorrectly or very inefficiently. Some influential computer scientists
strongly believe that unless the correctness of a computer program is proven with
full mathematical rigor, the program cannot be considered correct. They have de-
veloped special techniques for doing such proofs (see [Gri81]), but the power of
these techniques of formal verification is limited so far to very small programs.
As a practical matter, the validity of programs is still established by testing. Test-
ing of computer programs is an art rather than a science, but that does not mean
that there is nothing in it to learn. Look up books devoted to testing and debug-
ging; even more important, test and debug your program thoroughly whenever
you implement an algorithm.
Also note that throughout the book, we assume that inputs to algorithms fall
within their specified ranges and hence require no verification. When implement-
ing algorithms as programs to be used in actual applications, you should provide
such verifications.
1. I found this call for design simplicity in an essay collection by Jon Bentley [BenOO]; the essays deal
with a variety of issues in algorithm design and implementation, and arc justifiably titled Programming
Pearls. I wholeheartedly recommend writings of both Jon Bentley and Antoine de Saint-Exup6ry.
r I,
.
!'!
'
16 Introduction
il j
!
I
1.2 Fundamentals of Algorithmic Problem Solving 17
-----Exercises 1 . 2 - - - - - - - - - - - - - - -
1. Old World puzzle A peasant finds himself on a riverbank with a wolf, a goat,
and a head of cabbage. He needs to transport all three to the other side of the
river in his boat. However, the boat has room for only the peasant himself
and one other item (either the wolf, the goat, or the cabbage). In his absence,
the wolf would eat the goat, and the goat would eat the cabbage. Solve this
problem for the peasant or prove it has no solution. (Note: The peasant is a
vegetarian but does not like cabbage and hence can eat neither the goat nor
the cabbage to help him solve the problem. And it goes without saying that
the wolf is a protected species.)
2. New World puzzle There are four people who want to cross a bridge; they
all begin on the same side. You have 17 minutes to get them all across to
the other side. It is night, and they have one flashlight. A maximum of two
people can cross the bridge at one time. Any party that crosses, either one
or two people, must have the flashlight with them. The flashlight must be
walked back and forth; it cannot be thrown, for example. Person 1 takes 1
minute to cross the bridge, person 2 takes 2 minutes, person 3 takes 5 minutes,
and person 4 takes 10 minutes. A pair must walk together at the rate of the
slower person's pace. For example, if person 1 and person 4 walk across first,
10 minutes have elapsed when they get to the other side of the bridge. If person
4 returns the flashlight, a total of 20 minutes have passed and you have failed
the mission. (Note: According to a rumor on the Internet, interviewers at a
well-known software company located near Seattle have given this problem
to interviewees.)
3. Which of the following formulas can be considered an algorithm for comput-
ing the area of a triangle whose side lengths are given positive numbers a, b,
and c?
18 Introduction
Thus it will be seen that every inference drawn from Mr. Mann’s
tables has proved false.
Dissent has not, during the half century, supplied four times as much
new accommodation as the Church—if it has supplied any more at
all, the excess does not amount to a fourth.
Dissent has not, during the last 20 years, supplied three times as
much accommodation as the Church—it has barely supplied half as
much.
Dissent is not advancing at a pace twice as rapid as the Church; on
the contrary, the Church is advancing at nearly three times the
speed of Dissent.
Dissent has not improved its position, and the Church has not lost
position since 1831; on the contrary, the Church has gained, and
Dissent has lost, ground since that year.
Finally, as churches, save only where there is an excess of
accommodation as compared with the population, are at least as
well attended as dissenting places of worship, the charge of
comparative inefficiency which has been so rashly brought against
the clergy proves to be utterly without foundation.
Here, then, the present inquiry might be brought to a close; and yet
it would be palpably unfair to the Church to rest the case upon a
mere comparison of the additional sittings supplied by her rivals and
by herself. A new church, generally speaking, means a very
different thing from a new meeting-house. It means a substantially
built and even highly-decorative structure, the freehold of which is
the property of the community to which it belongs; it means decent
and becoming furniture for the performance of divine service;
provision for a properly educated minister in perpetuity; service
performed at least twice every Sunday, or even twice every day; a
house for the resident minister; a day-school, or rather a group of
day-schools; and a host of other benevolent and educational
agencies. If the establishment of the day-school be taken as a
criterion how far the parochial machinery has been completed, the
following table from the report of the Educational Census will be
instructive:—
Day Schools Supported by Religious Bodies.
So that in the afternoon, with only 537 fewer places open, the
number of sittings was 1,139,759 fewer than in the morning. In the
evening (when, of course, all the more important buildings which
were open in the morning were again accessible to the public) the
exertions of 3,744 additional preachers, nearly a third more, only
rendered available 337,850 additional sittings, or about one-eleventh
more; and they attracted only 97,668 additional hearers, an increase
of less than one in twenty-one! It may, perhaps, be allowable to
doubt whether the labours of non-resident, non-professional
preachers can be attended with any results worth speaking of; but,
at all events, their irregular ministrations can have no real bearing
on the question whether the regular meeting-houses are used more
or less frequently than the churches. Obviously, the fairest way
would be to inquire which class of buildings are opened the oftener
throughout the whole week; and, in that case, there is no doubt that
the comparison would show greatly in favour of the churches. If,
however, we must confine ourselves to Sunday, the proper question
to ask would be—in how many cases there is a service before, and
another after, noon? The answer, according to Table 16, would be
as follows:—
Church loss since 1801, 17; Dissenting gain, 26: total Church loss,
43.
Church gain since 1831, 56; Dissenting loss, 9; total Church gain,
65.
This, then, is really the rate at which each body “is advancing in the
path of self extension;” and the best proof of its accuracy is, that it
exactly tallies with what one would have expected beforehand. Mr.
Mann’s tables, on the contrary, are absolutely incredible. We must
never forget, that during the Great Rebellion, Puritanism was
actually the dominant faction; and even at the Restoration it cannot
be supposed that the Dissenters were a small or an uninfluential
class. In 1662 no fewer than 2,000 ministers were ejected under
the new Act of Uniformity; and as at the last census there were only
6405 professional Protestant Ministers, it will be seen that the
ejected preachers alone formed a larger body, in comparison with
the existing population, than the Protestant Dissenting Ministry does
now. It cannot be doubted that every one of those men had a
greater or less following; and it must be remembered that in the
days of the Commonwealth there was always a rabble of sects who
might even then be called Dissenters. It is true that, after the
Restoration, Nonconformity was subjected to severe repressive laws,
but those laws were not enforced with unvarying rigour. In 1672
there was the Indulgence, and in 1681 the House of Commons
passed a strong resolution against the prosecution of Protestant
Dissenters. Besides, after all, the Conventicle Acts only continued in
force about 23 years—not much longer, in fact, than Episcopacy had
been proscribed by law. The natural result which would follow the
famous proclamation of James II., and the subsequent passing of
the Toleration Act, would be a great and sudden revival of Dissent.
How small was the church-feeling of Parliament at the Revolution
may be gathered from a curious fact mentioned in Mr. Macaulay’s
third volume. It was proposed that the Commons should sit on
Easter Monday. The Churchmen vigorously protested against the
innovation; but they did not dare to divide, and the House did sit on
the festival in question. Without at all straining the inference to be
drawn from this incident, it would be difficult, indeed, to suppose
that Churchmen had matters their own way. Even under the penal
laws, the Dissenters must have been a large body; for James the
Second’s scheme for forming a coalition of Roman Catholic and
Protestant Dissenters against the Establishment would have been
stark folly unless the two bodies, when combined, would have made
up, at least, a powerful minority. From the Revolution to 1801 the
Dissenters had more than a century to increase and multiply; and all
the circumstances of the case were in their favour. Worn out by the
political struggles of a century and a half, during which she had been
made the tool of contending factions; deprived of her Legislative
powers; silenced and frowned upon by the powers that were, the
Church had sunk into that fatal lethargy from which the present
generation has only just seen her awake. During that long and
dreary period, all the prominent theologians, with a few bright
exceptions, were either Dissenters or inclined to Dissent. The
eighteenth century, too, was the golden age of popular
Nonconformist preachers. Not to mention a host of smaller names,
Wesley and Whitfield both rose, flourished, and died before its
close. And yet, if we are to believe Mr. Mann, the Dissenters in 1801
were a much smaller body, compared with the whole population,
than they were under the penal laws! [25] On the other hand, all
who remember the obloquy and contempt under which the Church
continued until the passing of the Reform Act, will reject, without a
moment’s hesitation, the notion that, in 1831, she actually
possessed more accommodation, in proportion to the population,
than at the present day. The change which has taken place in the
popular sentiment towards her has not been caused by any
document like this Census report, which suddenly appeared and
disabused the public mind of its preconceived ideas. It has, on the
contrary, been brought about by the silent influence of those
spectacles of zeal and self-denying liberality which have been
witnessed in every corner of the land. The Church has, in fact, lived
down her traducers. A hundred proverbs bear witness to the vast
amount of good deeds which are required to remove an evil
reputation; and yet Mr. Mann calls upon us to believe that the
Establishment has achieved this, although, with all her numbers and
all her wealth, she has not, since 1831, done so much as the
Wesleyan sects alone, towards supplying the people with the means
of religious instruction and worship! One has no language to
characterize such a daring attempt on the public credulity. The most
charitable hypothesis will be to conclude that Mr. Mann, though an
arithmetician by his office, knows nothing about arithmetic; and so
remit him to the consideration of Mr. Roebuck and the Administrative
Reform Society. [26]
The inquiry through which the reader has been invited to travel will
probably suggest several considerations; and first of all the
importance of putting a stop to the statistical nuisance which has of
late years flourished with so rank a growth. Surely it is time that
members of both Houses of Parliament, who resent so jealously any
attempt on the part of Government officials to exceed or fall short of
the precise instructions given them, in making returns, should raise
their voices against the system of publishing with official statistics
the crude, and, as it has been seen, the nonsensical but pernicious
theorizings of the persons entrusted with the task of compiling
reports. Like Mr. Mantalini, the majority of persons never trouble
themselves to examine a numerical process, but content themselves
with simply asking what is the total; and it therefore becomes the
duty of Parliament to see that the unsuspecting confidence of the
public is not abused. The reader must not suppose that the Report
on Religious Worship is the only recent one which is open to
objection. The Census Report on Schools is just as full of fallacies;
and it has certainly been one of the strangest phenomena ever
witnessed in the history of public discussion, that the schemes of
Lord John Russell and Sir John Pakington, assailed as they were on
every side, should have escaped what would, after all, have been
the most effective blow that could have been aimed against them—
the simple but conclusive fact, so easily deducible from the premises
of the Report on Schools, that nearly as many children were under
education as could be induced to attend unless they were driven to
the class of the teacher by the policeman’s staff. [27]
Again, the inquiry will probably satisfy the reader that the anti-
Church legislation of the day ought to proceed no further. It is easy
to assign the cause which in the first instance gave it birth. Most
statesmen, it may be presumed, will be ready to adopt, with regard
to the multifarious sects of modern Christianity, the last clause, at
least, of Gibbon’s famous dictum respecting the ancient religions of
Pagan Rome—“to the people equally true, to the philosopher equally
false, to the magistrate equally useful.” Persons who profess with
sincerity almost any form of Christian doctrine are comparatively
easy to govern; they throw but a light burden upon the poor-rate
and they cost nothing at all in the shape of police. A statesman,
then, might dislike Dissent, but what was he to say to a state of
things like that revealed in the Census report? The Church,
according to Mr. Mann’s tables, could not, by dint of the utmost
exertions she is ever likely to put forth, find accommodation for half
the souls who are year by year added to the population. On the
other hand the Dissenters, who are far less wealthy, and have few
endowments, provide without difficulty and without fuss more than
twice the amount of new accommodation supplied by the Church.
The irresistible inference in the mind of a mere statesman would be
that Dissent ought to be aided and encouraged. But if it turns out
that the facts are precisely the reverse of what has been represented
—if in reality Dissent is making no progress, while the Church is
providing new accommodation sufficient for the whole of the new
population—why should the Legislature go out of its path to foster
mere religious discord, and to impede the spread of what the
country has, after all, long since recognised as the “more excellent
way.” Why, for instance, should Churchrates be abolished? If they
were right in 1831, when there were more Dissenters and fewer
Churchmen, why are they wrong now? If Parliament has conferred
upon parishes, as a boon, the right to tax themselves (if a majority
of the ratepayers think fit) for the purpose of building and
maintaining public baths, museums, and libraries, why should
parishes now be deprived of a right which they possessed before
there was a Chancellor of the Exchequer or a budget—before the
Norman set foot upon our shores, or there was a House of
Commons worthy of the name—the right to tax themselves in order
to maintain edifices which may be museums second in interest to
none, and which may have been centres of enlightenment long
before the days of Caxton and Guttenberg?
There is another view of the case which ought not to be overlooked
by statesmen who regard a religious Establishment as a mere matter
of police. Granting that Dissent teaches men to be neither
drunkards nor thieves, is it calculated to make them as good citizens
and as good neighbours as the Church? The answer must surely be
a negative. The common consent of mankind has pronounced the
famous descriptions of the old Puritans in “Hudibras” to be almost as
applicable to modern Dissenters as to their ancient prototypes. Nor,
indeed, would it be easy, if they were not, to account for the
popularity of Butler’s oft-quoted lines; for even just satires, to say
nothing of unjustifiable lampoons, rarely survive the persons against
whom they are directed. Of course, men are often much better than
the system to which they belong. There are hundreds—nay,
thousands—of Dissenters whose Dissent is a mere accident of birth
and education, and who are truly catholic at heart; but of Dissent in
the abstract, no one who has either studied its history or is
acquainted with its practical working will deny the applicability to it
not only of Butler’s portraiture, but of another yet more famous
description, qualified in the latter case, however, with the insertion
or omission throughout of the important word—“not.” Dissent
suffers not long, and is not kind—Dissent is envious—behaves itself
unseemly—vaunts itself, and is puffed up—seeks every tittle of its
“rights”—is easily provoked—thinks evil—gloats over every slip on
the part of its opponents—attributes what is good in them to a
wrong motive—will bear nothing of which it can rid itself by agitation
or clamour—will put a good construction upon nothing when an evil
one is possible—hopes nothing—endures nothing. If this were not
so, how would it be possible to account for its inveterate propensity
to internal schism? The scriptural account of the Kingdom of Heaven
is that it should grow as from a seed; but Dissent is propagated
chiefly by cuttings. It is not yet two hundred years since the Kirk
was established in Scotland, and yet there are no fewer than six
sorts of Presbyterians. The case of Wesleyanism is still worse.
Within sixty years after the death of its founder it had split into
seven antagonistic sects. Whitfield himself quarrelled with Wesley,
and his followers have, since his death, separated into two bodies.
There are four sorts of Baptists. Of the Independents, Mr. Mann
speaks with refreshing innocence as forming “a compact and
undivided body.” It would be nearer the truth to say that they
consist of nearly as many sects as there are meeting-houses. Nearly
every congregation is of volcanic origin, and every one contains
within it elements which might at any moment explode and shatter
the whole concern.
That the writer may not be thought to be unsupported by facts, he
will here summarize the history of Anabaptistic and Congregational
Dissent in the first town to the annals of which he has ready access
—Nottingham, his authority being Mr. Wylie’s local history, published
in 1853. Nottingham, however, is a remarkably good example for
the purpose. It has a manufacturing population of 57,000, having
doubled itself since 1801. It is almost at the head of those places in
which Dissent is most rampant, and the Church most depressed. It
possessed, according to Mr. Mann’s table K, 35.2 Dissenting sittings
to every hundred inhabitants, the only other places equal or superior
to it in that respect being Merthyr Tydvil (52.4), Sunderland (35.2),
Rochdale (36.5), and Swansea (42.8). It boasts of 74.1 per cent. of
the whole religious accommodation within its boundaries, the only
places having more being Merthyr (89.7), and Rochdale (78.7).
This is truly edifying and amusing. First of all, mark the habitat of
this Nonconformist phœnix, a congregation which has actually given
birth to another without a preliminary quarrel. We must actually
cross the Atlantic, and seek the phenomenon in the land where the
penny-a-liner places his sea-serpents, and his other choicer
wonders. To increase without envy, hatred, and uncharitableness is,
it seems, to a Dissenter, something inexpressibly “noble”—and
brotherly love is something that must be “sternly” acted upon! We
may be quite certain that it is something the congregational sects
very rarely see, or it would not throw them into such lamentable,
and yet, in some sense, ludicrous contortions of surprise.
Perhaps some Dissenter will be whispering, after the manner of Mr.
Roebuck, the three words, Gorham, Liddell, Denison; but the tu
quoque wholly fails. In the first place, it is the surprising peculiarity
of the present Church controversies that the noisiest, if not the
weightiest, disputants are not Churchmen at all. In the next place,
those who are Churchmen, and enter with any bitterness into the
strife, are remarkable neither for their number nor their influence.
The great party in the Church of England is, after all, the middle
party; and however fierce the cannonade which the extreme left,
and its allies outside the pale, may direct against the extreme right,
their missiles fly harmlessly over the vast body which lies between.
The truth is, the recent outburst of controversy, so far as the Church
herself is responsible for it, is nothing but the natural recoil of that
conservative sentiment which must always be a powerful feeling in a
religious community, from doctrines and usages which had become
unfamiliar. As the unfamiliarity passes away, the controversy will
also gradually cease. Already the doctrines and usages in question
have been unconsciously adopted by many of those who fancy
themselves most opposed to them; and, indeed, if our doughtiest
combatants would only take pains to understand what it is their
antagonists really hold, they would often find that they are fighting
against mere shadows. The recent suits in the ecclesiastical courts
cannot but open the eyes of Churchmen to the extreme tenuity of
the points in dispute. Take the S. Barnabas case. Everybody will
remember the language which was applied to the “practices” revived
by Mr. Bennett. “Popish,” “histrionic,” “mummery,” were the mildest
terms in the repertory of that gentleman’s assailants. Those
“practices” remain to this day—if anything, they have been
elaborated rather than subjected to any mitigating process. Messrs.
Westerton and Beal bring the matter before the proper tribunal; but
what are the only issues they can find to raise? Such notable
questions as whether the cross, which glitters on the crown, the orb,
and sceptre of the Sovereign, which glows on the national banner,
which crowns almost every church gable in the land, with which
every Churchman is marked at his baptism, which the very Socinians
place upon their buildings, is, forsooth, a lawful ornament?—whether
a table ceases to be a table by being made of stone?—whether the
altar which has never been moved these two hundred years, and
which nobody wants to move, must nevertheless be movable?—
whether the altar vestments and the “fair linen cloths” used during
Communion time, may have fringes, or must be plain-hemmed?
Even if Dr. Lushington’s judgment should eventually be confirmed, if
in this age of schools of design, Mr. Westerton’s crusade against art
should prove successful, the alterations that would be made at S.
Barnabas would be discernible by none out the keenest eyes—so
little can there be found in matters ritual to fight about. Even in the
Denison case the points of difference are almost as infinitesimal. It
is true that under the revived act of Elizabeth—compared with which
the laws of Draco seem a mild and considerate code—the
Archdeacon has been sentenced to lose his preferments; but his
doctrine on the Real Presence has, in sober fact, never been so
much as challenged. His opponents, passing over all that was
material in his propositions, have only attacked a quasi corollary
which he has added to his main position, but which is, in reality, a
complete non-sequitur. Whether Dr. Lushington is right or wrong, it
is clear that a person holding the dogma of transubstantiation itself
might, with perfect logical consistency, accept the ruling of the
Court.
The differences between the highest and the lowest schools being so
impalpable, it would seem absurd to suppose that the present
controversies can have a much longer continuance. But whether
that be so or not, there is a very important distinction (and one that
is well worth the notice of statesmen) between the extension of the
Church and the spread of Dissent. Church extension, as far as it
goes, tends to compose differences. The consecration of a new
church is almost invariably regarded as an occasion when party
differences should be laid aside—the opening of a new meeting-
house is too commonly the crowning act of an irreparable schism.
Another lesson which the report of Mr. Mann ought to teach
Churchmen is the necessity there is for insisting upon the next
religious census being made a complete and accurate one. The next
religious census ought to include all such institutions as colleges,
workhouses, hospitals, and the like—it ought to be enforced by the
same penalties as the civil census; and it ought to be understood
that all the returns would be printed in a blue book. With these
precautions the Church need not fear the result. Even if the census
of 1861 should prove no more trustworthy than that of 1851, it will
remove a great deal of the misconceptions to which the latter has
given rise. As far as one may judge, the work of church extension is
progressing just as rapidly now as it was ten years ago; the number
of the clergy is just as rapidly augmenting; [33] and as all additional
clergymen have now to be supported on the voluntary principle, we
may presume that they follow the ordinary laws of supply and
demand. We may, therefore, confidently expect that the number of
church sittings open on the census morning in 1861 will not be
fewer than six millions; and if there be an average attendance
(which there was not on the last occasion) the number of persons
present will be about three millions and a half. That the Dissenters
will be able to open any more sittings than in 1851, is doubtful; for it
must be remembered that since 1841 the Church has been annually
absorbing a population equal to the entire yearly increase. But
allowing them the same increase as has been assigned to them for
the decade 1841–51, they will not be able to open more than four
million sittings, and they will not have more than two millions and a
half of attendants. This estimate is formed on the supposition that
the next census will be made on the voluntary principle like the last.
If a more complete and accurate account is taken, the result may be
very different. It is quite within the bounds of possibility that the
number of church attendants may turn out to be near four millions,
while that of the Dissenters may not much exceed two.
Looking at all the facts of the case, there is every reason why the
Church should take courage. Never since the Reformation has she
had so much real power for good—never has she been so free from
abuses. Each year sees thousands returning to the fold from which
they or their parents had strayed; each year sees her enemies more
and more “dwindle, peak, and pine.” Everything, too, points to a
daily acceleration of the process. At the very time that Convocation
is resuming its functions, the Non-conformist Union is compelled by
internal dissentions to abandon their yearly meeting. What Mr. Miall
calls “the dissidence of dissent”—that is to say, all in it that is pre-
eminently narrow-minded, ignorant, and infected with bigotry—is
concentrating itself, and is thus getting free the more respectable
elements of modern non-conformity. Meanwhile the better class of
Dissenters are doing all in their power to cut the ground from under
their own feet. They are building “steeple-houses,” inventing
liturgies, and adopting even choral services; in other words they are
expressing in the most emphatic manner their opinion that the
whole theory of dissent is wrong. For a short time a Brummagem
ecclesiology may satisfy them; but in the end they will no doubt rank
themselves amongst the best sons of the Church. The truth is, there
is no other religious community at the present day which can bid so
high for the reverent attachment of Englishmen. Whatever the
claims of Rome—her antiquity, her catholicity, her apostolicity—they
are equally the Church of England’s. Her succession of bishops is
the same, her regard for the primitive church greater, her conception
of Christendom far more grand. The glories of the ancient rituals
belong equally to the Book of Common Prayer. It contains nothing
material which was not in them, there was nothing material in them
(save only certain invocations and legends of the saints) which is not
in it. The Prayer Book is, in fact, nothing but a translation
(magnificently done) of the older offices, a little compressed and
simplified. The structure is the same—the mode of using it the
same; and if it has lost somewhat of the multiplied ceremonies
which were anciently observed, it has gained far more in the majesty
and breadth which it has acquired from its thoroughly congregational
character. Besides, it is throughout a reality, whereas the office
books of the Latin Communion have, to some extent at least,
become a sham. Thus the Breviary has long since been practically
abolished as a public form of prayer, and even as a manual of private
devotions for the clergy, that which forms its staple, the Book of
Psalms, has been virtually reduced to a fourth its bulk. In nearly a
thousand churches belonging to the Anglican communion the whole
Psalter is publicly recited every month, and in twenty times that
number it is said through twice every year.
If Protestant Dissenters boast of their enlightenment or of their
reverence for Scripture, the Church may meet them on that ground
likewise with the utmost confidence. The Prayer-book scarcely
recognises a person to be a Churchman if he cannot read; and she
directs some forty psalms and some thirty chapters of the Bible to be
gone through every week. In a word, approach the Church of
England from the most opposite points, and she will be found to
possess exactly that attribute which a person might think is most
admirable. The man who reverences antiquity—who has a taste for
art—who has a passion for ritual—who would have everything
“understanded of the people,”—he who insists upon ranks and
orders—and he who stands up for popular rights, will equally find in
the Church of this country the very quality which he deems
important. Never was there any institution so “many-sided;” never
one that became with so much success “all things to all men.” How
she could ever have lost her hold on the affections of Englishmen is
indeed wonderful; but, in truth, until lately, she has never had a
chance of making herself understood. Now, for the first time, her
theory is beginning to be appreciated; and the success which has
attended her, wonderful as it has been, is probably but the foretaste
of a future more brilliant than anything of which we can now form
an idea.
FOOTNOTES.
—the average being found by adding together the two lines and
dividing the sum by two. It need hardly, however, be pointed out
that the result so arrived at could not be true unless the number of
persons in each class was exactly the same. A man who had
invested in the Great Western Railway £900 which yielded him two
per cent., and £100 in the South Western which paid him six, might
say, on Mr. Mayhew’s principle, that he had invested £1000 at 4 per
cent; but he would soon find out that he would have to receive only
£24 for his yearly dividend instead of £40—£2.8 percent. instead of
£4.
[27] Mr. Mann calculates that without in the least interfering with
juvenile labour, and without questioning the discretion of parents
who kept children between the ages of 3 and 5 and 12 and 15 at
home, there ought to have been more than three million children at
school in 1851. It would be easy to show that this estimate is based
upon nothing better than a series of blunders and bad guesses, but
there is a much shorter mode of dealing with it. The children of the
middle and upper classes do not remain under professional
instructors at home or at school for a longer average period than six
years. Now, the total number of children in 1851 between the ages
of 4 and 10 was 2,484,866, or 13.8 per cent. of the entire
population. The number actually on the school books was
2,200,000, or 12.2 per cent. So that either all the children in the
country were at school, but the average time was one-eighth too
short; or the average time was of the right length, but the number
of scholars was one-eighth too few. The truth, of course, lay
somewhere between these two alternatives. Since 1851
considerable progress has no doubt been made; but it unfortunately
turns out that the effect of improved machinery is not to improve the
general education, but merely to shorten the time allotted to
schooling. It is found that if by better modes of tuition a child can
be made sooner to acquire what its parents think sufficient for it to
know, it is only so much the sooner taken away. It would therefore
be vain to expect that the school per centage will ever be much
higher than it was in 1851—at least, until the middle classes raise
their own standard. Of the children on the schoolbooks in 1851, the
per centage of actual daily attendants was 83—91 for the private,
and 79 for the public scholar. In America, where the schools are
wholly free, the per centage was still less. In Massachusetts, for
example, it was only 75. In other words, the attendance in England
and Wales in 1851 was 1,826,000 daily. If the 2,200,000 had all
been private scholars, it would have been 2,002,000. On the other
hand if there had been 2,400,000 free scholars, it would only have
been 1,800,000. These figures will speak for themselves.
[33] The number of additional clergy ordained every year is stated
to be 300. The number required to maintain the proportion of clergy
to population which existed in 1851 would be under 200.
*** END OF THE PROJECT GUTENBERG EBOOK THE TRUTH ABOUT
CHURCH EXTENSION ***
Updated editions will replace the previous one—the old editions will
be renamed.
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.
ebooknice.com