0% found this document useful (0 votes)
0 views

Data Structures and Algorithm Analysis in Java 数据结构与算法分析 Java语言描述 数据结构与算法分析 Weiss download

The document is a comprehensive overview of 'Data Structures and Algorithm Analysis in Java' by Mark Allen Weiss, detailing various data structures, algorithm analysis, and their implementations in Java. It includes chapters on lists, stacks, queues, trees, hashing, priority queues, and sorting, along with mathematical background and exercises for practice. The text serves as a resource for understanding core concepts in computer science and programming.

Uploaded by

calfyhynekd6
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Data Structures and Algorithm Analysis in Java 数据结构与算法分析 Java语言描述 数据结构与算法分析 Weiss download

The document is a comprehensive overview of 'Data Structures and Algorithm Analysis in Java' by Mark Allen Weiss, detailing various data structures, algorithm analysis, and their implementations in Java. It includes chapters on lists, stacks, queues, trees, hashing, priority queues, and sorting, along with mathematical background and exercises for practice. The text serves as a resource for understanding core concepts in computer science and programming.

Uploaded by

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

Data Structures and Algorithm Analysis in Java

■■■■■■■■■ Java■■■■ ■■■■■■■■■ Weiss download

https://ebookultra.com/download/data-structures-and-algorithm-
analysis-in-java-
%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84%e4%b8%8e%e7%ae%97%e6%b3%95%e
5%88%86%e6%9e%90-java%e8%af%ad%e8%a8%80%e6%8f%8f%e8%bf%b0-
%e6%95%b0%e6%8d%ae%e7%bb%93/

Explore and download more ebooks or textbooks


at ebookultra.com
We have selected some products that you may be interested in
Click the link to download now or visit ebookultra.com
for more options!.

The Anti Alapin Gambit Death to the 2 c3 Sicilian 1st


Edition Cyrus Lakdawala

https://ebookultra.com/download/the-anti-alapin-gambit-death-to-
the-2-c3-sicilian-1st-edition-cyrus-lakdawala/

Quick easy mexican cooking more than 80 everyday recipes


Lee

https://ebookultra.com/download/quick-easy-mexican-cooking-more-
than-80-everyday-recipes-lee/

Advances in Computers 80 1st Edition Marvin Zelkowitz


Ph.D. Ms Bs.

https://ebookultra.com/download/advances-in-computers-80-1st-edition-
marvin-zelkowitz-ph-d-ms-bs/

Pareto s 80 20 Rule for Corporate Accountants 1st Edition


David Parmenter

https://ebookultra.com/download/pareto-s-80-20-rule-for-corporate-
accountants-1st-edition-david-parmenter/
Pies Sweet and Savory Recipes from over 80 Great Chefs 1st
Edition Alan Batt

https://ebookultra.com/download/pies-sweet-and-savory-recipes-from-
over-80-great-chefs-1st-edition-alan-batt/

Frommer s Washington D C from 80 a Day 1st Edition Elise


Hartman Ford

https://ebookultra.com/download/frommer-s-washington-d-c-
from-80-a-day-1st-edition-elise-hartman-ford/

A Whisper of Cardamom 80 Sweetly Spiced Recipes to Fall in


Love With Eleanor Ford

https://ebookultra.com/download/a-whisper-of-cardamom-80-sweetly-
spiced-recipes-to-fall-in-love-with-eleanor-ford/

Authentic Recipes from China 80 Simple and Delicious


Recipes from the Middle Kingdom Kenneth Law

https://ebookultra.com/download/authentic-recipes-from-
china-80-simple-and-delicious-recipes-from-the-middle-kingdom-kenneth-
law/

EcoRedux Design Remedies for an Ailing Planet


Architectural Design November December 2010 Vol 80 No 6
1st Edition Kallipoliti Lydia
https://ebookultra.com/download/ecoredux-design-remedies-for-an-
ailing-planet-architectural-design-november-
december-2010-vol-80-no-6-1st-edition-kallipoliti-lydia/
Data Structures and Algorithm Analysis in Java
æ•°æ​®ç»“构与算法分æž​ Javaè¯​言æ​​è¿°
æ•°æ​®ç»“构与算法分æž​ Weiss Digital Instant
Download
Author(s): Weiss, Mark Allen
ISBN(s): 9787111412366, 7111412362
Edition: Reprinted ed.
File Details: PDF, 2.99 MB
Year: 2011
Language: english
This page intentionally left blank
International Edition contributions by
Arup Kumar Bhattacharjee
RCC Institute of Information Technology

Soumen Mukherjee
RCC Institute of Information Technology

Boston Columbus Indianapolis New York San Francisco Upper Saddle River
Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montreal Toronto
Delhi Mexico City Sao Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo
Editorial Director: Marcia Horton Publishing Assistant, International
Editor-in-Chief: Michael Hirsch Edition: Shokhi Shah
Editorial Assistant: Emma Snider Print and Media Editor, International
Director of Marketing: Patrice Jones Edition: Ashwitha Jayakumar
Marketing Manager: Yezan Alayan Project Editor, International Edition:
Marketing Coordinator: Kathryn Ferranti Jayashree Arunachalam
Director of Production: Vince O’Brien Art Director: Jayne Conte
Managing Editor: Jeff Holcomb Cover Designer: Bruce Kenselaar
Production Project Manager: Kayla Cover Photo: De-Kay
c Dreamstime.com
Smith-Tarbox Media Editor: Daniel Sandin
Project Manager: Pat Brown Full-Service Project Management: Integra
Manufacturing Buyer: Pat Brown Cover Printer: Lehigh-Phoenix
Publisher, International Edition: Angshuman Color/Hagerstown
Chakraborty
Acquisitions Editor, International Edition:
Somnath Basu

Pearson Education Limited


Edinburgh Gate
Harlow
Essex CM20 2JE
England
and Associated Companies throughout the world
Visit us on the World Wide Web at:
www.pearsoninternationaleditions.com

c Pearson Education Limited 2012
The right of Marl Allen Weiss to be identified as author of this work has been asserted by him in accordance with the
Copyright, Designs and Patents Act 1988.
Authorized adaptation from the United States edition, entitled Data Structures and Algorithm Analysis in Java, 3rd edition,
ISBN 9780-13-257627-7 by Mark Allen Weiss published by Pearson Education  c 2012.
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 either the prior written
permission of the publisher or a licence permitting restricted copying in the United Kingdom issued by the Copyright
Licensing Agency Ltd, Saffron House, 6–10 Kirby Street, London EC1N 8TS.
All trademarks used herein are the property of their respective owners. The use of any trademark in this text does not
vest in the author or publisher any trademark ownership rights in such trademarks, nor does the use of such trademarks
imply any affiliation with or endorsement of this book by such owners.
Microsoft
R and Windows R are registered trademarks of the Microsoft Corporation in the U.S.A. and other countries.
Screen shots and icons reprinted with permission from the Microsoft Corporation. This book is not sponsored or
endorsed by or affiliated with the Microsoft Corporation.
British Library Cataloguing-in-Publication Data
A catalogue record for this book is available from the British Library
10 9 8 7 6 5 4 3 2 1
14 13 12 11 10
Typeset in Berkeley-Book by Integra
Printed and bound by Courier Berkeley-Book Westford in The United States of America
The publisher’s policy is to use paper manufactured from sustainable forests.

ISBN 10: 0-273-75211-1


ISBN 13: 978-0-273-75211-0
To the love of my life, Jill.
This page intentionally left blank
CONTENTS

Preface 17

Chapter 1 Introduction 21
1.1 What’s the Book About? 21
1.2 Mathematics Review 22
1.2.1 Exponents 23
1.2.2 Logarithms 23
1.2.3 Series 24
1.2.4 Modular Arithmetic 25
1.2.5 The P Word 26
1.3 A Brief Introduction to Recursion 28
1.4 Implementing Generic Components Pre-Java 5 32
1.4.1 Using Object for Genericity 33
1.4.2 Wrappers for Primitive Types 34
1.4.3 Using Interface Types for Genericity 34
1.4.4 Compatibility of Array Types 36
1.5 Implementing Generic Components Using Java 5 Generics 36
1.5.1 Simple Generic Classes and Interfaces 37
1.5.2 Autoboxing/Unboxing 38
1.5.3 The Diamond Operator 38
1.5.4 Wildcards with Bounds 39
1.5.5 Generic Static Methods 40
1.5.6 Type Bounds 41
1.5.7 Type Erasure 42
1.5.8 Restrictions on Generics 43

7
8 Contents

1.6 Function Objects 44


Summary 46
Exercises 46
References 48

Chapter 2 Algorithm Analysis 49


2.1 Mathematical Background 49
2.2 Model 52
2.3 What to Analyze 53
2.4 Running Time Calculations 55
2.4.1 A Simple Example 56
2.4.2 General Rules 56
2.4.3 Solutions for the Maximum Subsequence Sum Problem 59
2.4.4 Logarithms in the Running Time 65
2.4.5 A Grain of Salt 69
Summary 69
Exercises 70
References 75

Chapter 3 Lists, Stacks, and Queues 77


3.1 Abstract Data Types (ADTs) 77
3.2 The List ADT 78
3.2.1 Simple Array Implementation of Lists 78
3.2.2 Simple Linked Lists 79
3.3 Lists in the Java Collections API 81
3.3.1 Collection Interface 81
3.3.2 Iterator s 81
3.3.3 The List Interface, ArrayList, and LinkedList 83
3.3.4 Example: Using remove on a LinkedList 85
3.3.5 ListIterators 87
3.4 Implementation of ArrayList 87
3.4.1 The Basic Class 88
3.4.2 The Iterator and Java Nested and Inner Classes 91
3.5 Implementation of LinkedList 95
3.6 The Stack ADT 102
3.6.1 Stack Model 102
Contents 9

3.6.2 Implementation of Stacks 103


3.6.3 Applications 104
3.7 The Queue ADT 112
3.7.1 Queue Model 112
3.7.2 Array Implementation of Queues 112
3.7.3 Applications of Queues 115
Summary 116
Exercises 116

Chapter 4 Trees 121


4.1 Preliminaries 121
4.1.1 Implementation of Trees 122
4.1.2 Tree Traversals with an Application 123
4.2 Binary Trees 127
4.2.1 Implementation 128
4.2.2 An Example: Expression Trees 129
4.3 The Search Tree ADT—Binary Search Trees 132
4.3.1 contains 133
4.3.2 findMin and findMax 135
4.3.3 insert 136
4.3.4 remove 138
4.3.5 Average-Case Analysis 140
4.4 AVL Trees 143
4.4.1 Single Rotation 145
4.4.2 Double Rotation 148
4.5 Splay Trees 157
4.5.1 A Simple Idea (That Does Not Work) 157
4.5.2 Splaying 159
4.6 Tree Traversals (Revisited) 165
4.7 B-Trees 167
4.8 Sets and Maps in the Standard Library 172
4.8.1 Sets 172
4.8.2 Maps 173
4.8.3 Implementation of TreeSet and TreeMap 173
4.8.4 An Example That Uses Several Maps 174
Summary 180
Exercises 180
References 187
10 Contents

Chapter 5 Hashing 191


5.1 General Idea 191
5.2 Hash Function 192
5.3 Separate Chaining 194
5.4 Hash Tables Without Linked Lists 199
5.4.1 Linear Probing 199
5.4.2 Quadratic Probing 201
5.4.3 Double Hashing 203
5.5 Rehashing 208
5.6 Hash Tables in the Standard Library 209
5.7 Hash Tables with Worst-Case O(1) Access 212
5.7.1 Perfect Hashing 213
5.7.2 Cuckoo Hashing 215
5.7.3 Hopscotch Hashing 225
5.8 Universal Hashing 231
5.9 Extendible Hashing 234
Summary 237
Exercises 238
References 242

Chapter 6 Priority Queues (Heaps) 245


6.1 Model 245
6.2 Simple Implementations 246
6.3 Binary Heap 246
6.3.1 Structure Property 247
6.3.2 Heap-Order Property 249
6.3.3 Basic Heap Operations 249
6.3.4 Other Heap Operations 254
6.4 Applications of Priority Queues 258
6.4.1 The Selection Problem 258
6.4.2 Event Simulation 259
6.5 d-Heaps 260
6.6 Leftist Heaps 261
6.6.1 Leftist Heap Property 261
6.6.2 Leftist Heap Operations 262
6.7 Skew Heaps 269
Contents 11

6.8 Binomial Queues 272


6.8.1 Binomial Queue Structure 272
6.8.2 Binomial Queue Operations 273
6.8.3 Implementation of Binomial Queues 276
6.9 Priority Queues in the Standard Library 281
Summary 281
Exercises 283
References 287

Chapter 7 Sorting 291


7.1 Preliminaries 291
7.2 Insertion Sort 292
7.2.1 The Algorithm 292
7.2.2 Analysis of Insertion Sort 292
7.3 A Lower Bound for Simple Sorting Algorithms 293
7.4 Shellsort 294
7.4.1 Worst-Case Analysis of Shellsort 296
7.5 Heapsort 298
7.5.1 Analysis of Heapsort 299
7.6 Mergesort 302
7.6.1 Analysis of Mergesort 304
7.7 Quicksort 308
7.7.1 Picking the Pivot 310
7.7.2 Partitioning Strategy 312
7.7.3 Small Arrays 314
7.7.4 Actual Quicksort Routines 314
7.7.5 Analysis of Quicksort 317
7.7.6 A Linear-Expected-Time Algorithm for Selection 320
7.8 A General Lower Bound for Sorting 322
7.8.1 Decision Trees 322
7.9 Decision-Tree Lower Bounds for Selection Problems 324
7.10 Adversary Lower Bounds 327
7.11 Linear-Time Sorts: Bucket Sort and Radix Sort 330
7.12 External Sorting 335
7.12.1 Why We Need New Algorithms 336
7.12.2 Model for External Sorting 336
7.12.3 The Simple Algorithm 336
12 Contents

7.12.4 Multiway Merge 337


7.12.5 Polyphase Merge 338
7.12.6 Replacement Selection 339
Summary 341
Exercises 341
References 347

Chapter 8 The Disjoint Set Class 351


8.1 Equivalence Relations 351
8.2 The Dynamic Equivalence Problem 352
8.3 Basic Data Structure 353
8.4 Smart Union Algorithms 357
8.5 Path Compression 360
8.6 Worst Case for Union-by-Rank and Path Compression 361
8.6.1 Slowly Growing Functions 362
8.6.2 An Analysis By Recursive Decomposition 363
8.6.3 An O( M log * N ) Bound 370
8.6.4 An O( M α(M, N) ) Bound 370
8.7 An Application 372
Summary 375
Exercises 375
References 377

Chapter 9 Graph Algorithms 379


9.1 Definitions 379
9.1.1 Representation of Graphs 380
9.2 Topological Sort 382
9.3 Shortest-Path Algorithms 386
9.3.1 Unweighted Shortest Paths 387
9.3.2 Dijkstra’s Algorithm 392
9.3.3 Graphs with Negative Edge Costs 400
9.3.4 Acyclic Graphs 400
9.3.5 All-Pairs Shortest Path 404
9.3.6 Shortest-Path Example 404
9.4 Network Flow Problems 406
9.4.1 A Simple Maximum-Flow Algorithm 408
Contents 13

9.5 Minimum Spanning Tree 413


9.5.1 Prim’s Algorithm 414
9.5.2 Kruskal’s Algorithm 417
9.6 Applications of Depth-First Search 419
9.6.1 Undirected Graphs 420
9.6.2 Biconnectivity 422
9.6.3 Euler Circuits 425
9.6.4 Directed Graphs 429
9.6.5 Finding Strong Components 431
9.7 Introduction to NP-Completeness 432
9.7.1 Easy vs. Hard 433
9.7.2 The Class NP 434
9.7.3 NP-Complete Problems 435
Summary 437
Exercises 437
References 445

Chapter 10 Algorithm Design


Techniques 449
10.1 Greedy Algorithms 449
10.1.1 A Simple Scheduling Problem 450
10.1.2 Huffman Codes 453
10.1.3 Approximate Bin Packing 459
10.2 Divide and Conquer 468
10.2.1 Running Time of Divide-and-Conquer Algorithms 469
10.2.2 Closest-Points Problem 471
10.2.3 The Selection Problem 475
10.2.4 Theoretical Improvements for Arithmetic Problems 478
10.3 Dynamic Programming 482
10.3.1 Using a Table Instead of Recursion 483
10.3.2 Ordering Matrix Multiplications 486
10.3.3 Optimal Binary Search Tree 489
10.3.4 All-Pairs Shortest Path 492
10.4 Randomized Algorithms 494
10.4.1 Random Number Generators 496
10.4.2 Skip Lists 500
10.4.3 Primality Testing 503
14 Contents

10.5 Backtracking Algorithms 506


10.5.1 The Turnpike Reconstruction Problem 507
10.5.2 Games 510
Summary 519
Exercises 519
References 528

Chapter 11 Amortized Analysis 533


11.1 An Unrelated Puzzle 534
11.2 Binomial Queues 534
11.3 Skew Heaps 539
11.4 Fibonacci Heaps 542
11.4.1 Cutting Nodes in Leftist Heaps 542
11.4.2 Lazy Merging for Binomial Queues 545
11.4.3 The Fibonacci Heap Operations 548
11.4.4 Proof of the Time Bound 549
11.5 Splay Trees 551
Summary 556
Exercises 556
References 558

Chapter 12 Advanced Data Structures


and Implementation 561
12.1 Top-Down Splay Trees 561
12.2 Red-Black Trees 569
12.2.1 Bottom-Up Insertion 569
12.2.2 Top-Down Red-Black Trees 571
12.2.3 Top-Down Deletion 576
12.3 Treaps 578
12.4 Suffix Arrays and Suffix Trees 580
12.4.1 Suffix Arrays 581
12.4.2 Suffix Trees 584
12.4.3 Linear-Time Construction of Suffix Arrays and Suffix Trees 587
12.5 k-d Trees 598
Random documents with unrelated
content Scribd suggests to you:
Two days after the date of this letter Allen sent a copy of it to the
Assembly of Connecticut, saying: "I thought it advisable that the
Honorable Assembly should be informed of all our politicks."
Allen shows great shrewdness in adapting his letters to what he
considers the aboriginal mind. Addressing the Indians constantly as
brothers he appeals to their love of bush-fighting, and as regards the
question of barter, to their love of rum. By his reiteration he
recognizes the childish immaturity of the Indian. Far differently he
addresses the Canadians, to whose reason he appeals and whose
sense of justice he compliments:

Ticonderoga, June 4.
Countrymen and Friends, the French people of Canada,
greeting:
Friends and Fellow-Countrymen:—You are undoubtedly more
or less acquainted with the unnatural and unhappy
controversy subsisting between Great Britain and her
Colonies, the particulars of which in this letter we do not
expatiate upon, but refer your considerations of the justice
and equitableness thereof on the part of the Colonies, to the
former knowledge that you have of this matter. We need only
observe that the inhabitants of the Colonies view the
controversy on their part to be justifiable in the sight of God,
and all unprejudiced and honest men that have or may have
opportunity and ability to examine into the merits of it. Upon
this principle those inhabitants determine to vindicate their
cause, and maintain their natural and constitutional rights and
liberties at the expense of their lives and fortunes, but have
not the least disposition to injure, molest, or in any way
deprive our fellow-subjects, the Canadians, of their liberty or
property. Nor have they any design to urge war against them;
and from all intimations that the inhabitants of the said
Colonies have received from the Canadians, it has appeared
that they were alike disposed for friendship and neutrality,
and not at all disposed to take part with the King's troops in
the present civil war against the Colonies.
We were, nevertheless, surprised to hear that a number of
about thirty Canadians attacked our reconnoitring party
consisting of four men, fired on them, and pursued them, and
obliged them to return the fire. This is the account of the
party that has since arrived at headquarters. We desire to
know of any gentlemen Canadians the facts of the case, as
one story is good until another is told. Our general order to
the soldiery was, that they should not, on pain of death,
molest or kill any of your people. But if it shall appear, upon
examination, that our reconnoitring party commenced
hostilities against your people, they shall suffer agreeable to
the sentence of a court-martial; for our special orders from
the Colonies are to befriend and protect you if need be; so
that if you desire their friendship you are invited to embrace
it, for nothing can be more undesirable to your friends in the
Colonies, than a war with their fellow-subjects the Canadians,
or with the Indians.
Hostilities have already begun; to fight with the King's
troops has become a necessary and incumbent duty; the
Colonies cannot avoid it. But pray, is it necessary that the
Canadians and the inhabitants of the English Colonies should
butcher one another? God forbid! There is no controversy
subsisting between you and them. Pray let old England and
the Colonies fight it out, and you, Canadians, stand by and
see what an arm of flesh can do. We conclude, Saint Luke,
Captain McCoy, and other evil-minded persons whose interest
and inclination is that the Canadians and the people of these
Colonies should cut one another's throats, have inveigled
some of the baser sort of your people to attack our said
reconnoitring party.

Allen signed this letter as "At present the Principal Commander of


the Army."
A copy of it was sent to Mr. Walker at Montreal by Mr. Jeffere.
Another copy was sent to the New York Provincial Congress.
John Brown, a young lawyer of Pittsfield, Massachusetts, was the
cause of Ethan Allen's long, terrible captivity. That alone justifies our
curiosity to know all about him. In March, before the war, he made
an eventful trip to Montreal, going along our borders, crossing the
lakes, visiting Bennington, engaging two pilots, contracting with the
foremost men there, spending days investigating the status of affairs
in Canada as to the coming struggle. Reporting to his employers,
Samuel Adams and Dr. Joseph Warren, he says that after stopping
about a fortnight at Albany he was fourteen days journeying to St.
John's, undergoing inconceivable hardships; the lake very high, the
country for twenty miles each side under water; the ice breaking
loose for miles; two days frozen in to an island; "we were glad to
foot it on land;" "there is no prospect of Canada sending delegates
to the Continental Congress." He speaks of his pilot, Peleg
Sunderland, as "an old Indian hunter acquainted with the St. Francis
Indians and their language." The other pilot was a captive many
years ago among the Caughnawaga Indians. This last was Winthrop
Hoit, of Bennington. These two men were famous for their familiarity
with Indian ways and speech, as well as for general prowess, and
their exploits in "beech-sealing" the Yorkers. Several days
Sunderland and Hoit were among the Caughnawagas, studying their
manifestations of feeling toward the colonists. Brown gave letters to
Thomas Walker and Blake, and pamphlets to four curés in La Prairie.
He was kindly received by the local committee, who told him about
Canadian politics, that Governor Carleton was no great politician, a
man of sour, morose temper, and so forth. Brown wrote Adams and
Warren he should not go to Quebec, "as a number of their
committee are here," but "I shall tarry here some time." "I have
established a channel of correspondence through the New
Hampshire Grants which may be depended on." "One thing I must
mention, to be kept as a profound secret. The fort at Ticonderoga
must be seized as soon as possible should hostilities be committed
by the King's troops. The people on New Hampshire Grants have
engaged to do this business." This letter was dated three weeks
before the Lexington and Concord fights electrified the continent.
CH APTER X.

WARNER ELECTED COLONEL OF THE GREEN MOUNTAIN BOYS.—ALLEN'S LETTER


TO GOVERNOR TRUMBULL.—CORRESPONDENCE IN REGARD TO THE INVASION
OF CANADA.—ATTACK ON MONTREAL.—DEFEAT AND CAPTURE.—WARNER'S
REPORT.

On July 27th committees of towns met at Dorset to choose a


lieutenant-colonel of the regiment, and thus of those Green
Mountain Boys for whose organization Allen had been so active and
efficient with both the Continental and New York Congresses. Seth
Warner received forty-one of the forty-six votes cast. Deep was
Allen's chagrin and mortification, as appears in the following letter to
Governor Trumbull:

Ticonderoga, August 3, 1775.


Honored Sir:—General Schuyler exerts his utmost in building
boats and making preparations for the army to advance, as I
suppose, to St. John's, etc. We have an insufficient store of
provisions for such an undertaking, though the projection is
now universally approved. Provisions are hurrying forward,
but not so fast as I could hope for. General Wooster's corps
has not arrived. I fear there is some treachery among the
New York Tory party relative to forwarding the expedition,
though I am confident that the General is faithful. No troops
from New York, except some officers, have arrived, though it
is given out that they will soon be here. The General tells me
he does not want any more troops till more provisions come
to hand, which he is hurrying; and ordered the troops under
General Wooster, part to be billeted in the mean while at
Albany and part to mend the road from there to Lake George.
It is indeed an arduous work to furnish an army to
prosecute an enterprise. In the interim, I am apprehensive,
the enemy are forming one against us; witness the sailing of
the transports and two men of war from Boston, as it is
supposed for Quebeck. Probably, it appears that the King's
Troops are discouraged of making incursions into the Province
of the Massachusetts Bay. Likely they will send part of their
force to overawe the Canadians, and inveigle the Indians into
their interest. I fear the Colonies have been too slow in their
resolutions and preparations relative to this department; but
hope they may still succeed.
Notwithstanding my zeal and success in my country's
cause, the old farmers on the New Hampshire Grants (who do
not incline to go to war) have met in a committee meeting,
and in their nomination of officers for the regiment of Green
Mountain Boys (who are quickly to be raised) have wholly
omitted me; but as the commissions will come from the
Continental Congress, I hope they will remember me, as I
desire to remain in the service, and remain your Honor's most
obedient and humble servant,
Ethan Allen.
To the Hon. Jona. Trumbull, Governor of the Colony of Connecticut.
N. B.—General Schuyler will transmit to your Honors a copy
of the affidavits of two intelligent friends, who have just
arrived from Canada. I apprehend that what they have
delivered is truth. I find myself in the favor of the officers of
the Army and the young Green Mountain Boys. How the old
men came to reject me I cannot conceive, inasmuch as I
saved them from the encroachments of New York.
E. A.

This Jonathan Trumbull, be it remembered, was the original


"Brother Jonathan."
Allen's first connection with the campaign in Canada is explained
in his own narrative:

Early in the fall of the year, the little army under the
command of the Generals Schuyler and Montgomery were
ordered to advance into Canada. I was at Ticonderoga when
this order arrived; and the General, with most of the field
officers, requested me to attend them in the expedition; and
though at that time I had no commission from Congress, yet
they engaged me, that I should be considered as an officer,
the same as though I had a commission; and should, as
occasion might require, command certain detachments of the
army. This I considered as an honorable offer, and did not
hesitate to comply with it.

September 8, 1775, from St. Therese, James Livingston wrote to


General Schuyler:

Your manifestos came to hand, and despatched them off to


the different Parishes with all possible care and expedition.
The Canadians are all friends, and a spirit of freedom seems
to reign amongst them. Colonel Allen, Major Brown and
myself set off this morning with a party of Canadians with
intention to go to your army; but hearing of a party of
Indians waiting for us the same side of the river, we thought
it most prudent to retire in order, if possible, to raise a more
considerable party of men. We shall drop down the River
Chambly, as far as my house, where a number of Canadians
are waiting for us.

September 10, 1775, at Isle-aux-Noix, General Schuyler in his


orders to Colonel Ritzemd, who was going into Canada with five
hundred men, says:
Colonel Allen and Major Brown have orders to request that
provisions may be brought to you, which must be punctually
paid for, for which purpose I have furnished you with the sum
of £318 1s. 10d. in gold.

September 15, 1775, at Isle-aux-Noix, General Schuyler received


from James Livingston a report in which he says:

Yesterday morning, I sent a party each side of the river,


Colonel Allen at their head, to take the vessels at Sorel, by
surprise if possible. Numbers of people flock to them, and
make no doubt they will carry their point. I have cut off the
communication from Montreal to Chambly. We have nothing
to fear here at present but a few seigneurs in the country
endeavoring to raise forces. I hope Colonel Allen's presence
will put a stop to it.

September 8, 1775, at Isle-aux-Noix, Schuyler writes Hancock:

I hope to hear in a day or two from Colonel Allen and Major


Brown, who went to deliver my declaration.

This refers to Schuyler's address to the inhabitants of Canada,


dated Isle-aux-Noix, September 5, 1775.
From Isle-aux-Noix, September 14, 1775, Ethan Allen reports to
General Schuyler:

Set out from Isle-aux-Noix on the 8th instant; arrived at


Chambly; found the Canadians in that vicinity friendly. They
guarded me under arms night and day, escorted me through
the woods as I desired, and showed me every courtesy I
could wish for. The news of my being in this place excited
many captains of the Militia and respectable gentlemen of the
Canadians to visit and converse with me, as I gave out I was
sent by General Schuyler to manifest his friendly intentions
toward them, and delivered the General's written manifesto to
them to the same purpose. I likewise sent a messenger to the
chiefs of the Caughnawaga Indians, demanding the cause
why sundry of the Indians had taken up arms against the
United Colonies; they had sent two of their chiefs to me, who
plead that it was contrary to the will and orders of their
chiefs. The King's troops gave them rum and inveigled them
to fight against General Schuyler; that they had sent their
runners and ordered them to depart from St. John's, averring
their friendship to the Colonies. Meanwhile the Sachems held
a General Council, sent two of their Captains and some beads
and a wampum belt as a lasting testimony of their friendship,
and that they would not take up arms on either side. These
tokens of friendship were delivered to me, agreeable to their
ceremony, in a solemn manner, in the presence of a large
auditory of Canadians, who approved of the league and
manifested friendship to the Colonies, and testified their
good-will on account of the advance of the army into Canada.
Their fears (as they said) were, that our army was too weak
to protect them against the severity of the English
Government, as a defeat on our part would expose our
friends in Canada to it. In this dilemma our friends expressed
anxiety of mind. It furthermore appeared to me that many of
the Canadians were watching the scale of power, whose
attraction attracted them. In fine, our friends in Canada
earnestly urged that General Schuyler should immediately
environ St. John's, and that they would assist in cutting off
the communication between St. John's and Chambly, and
between these forts and Montreal. They furthermore assured
me that they would help our army to provisions, etc., and that
if our army did not make a conquest of the King's garrisons,
they would be exposed to the resentment of the English
Government, which they dreaded, and consequently the
attempt of the army into Canada would be to them the
greatest evil. They further told me that some of the
inhabitants, that were in their hearts friendly to us, would, to
extricate themselves, take up arms in favor of the Crown; and
therefore, that it was of the last importance to them, as well
as to us, that the army immediately attack St. John's; which
would cause them to take up arms in our favor. Governor
Carleton threatens the Canadians with fire and sword, except
they assist him against the Colonies, and the seigneurs urge
them to it. They have withstood Carleton and them, and keep
under arms throughout most of their Parishes, and are now
anxiously watching the scale of power. This is the situation of
affairs in Canada, according to my most painful discovery.
Given under my hand, upon honor, this 14th day of
September, 1775.
Ethan Allen.
To his Excellency General Schuyler.

With one more letter from Allen (to General Montgomery) we will
close his correspondence on the invasion of Canada, which he so
strongly urged, so shrewdly planned, and yet which failed from lack
of the co-operation of others:

St. Tours, September 20, 1775.


Excellent Sir:—I am now in the Parish of St. Tours, four
leagues to the south; have two hundred and fifty Canadians
under arms; as I march they gather fast. These are the
objects of taking the vessels in Sorel and General Carleton.
These objects I pass by to assist the army besieging St.
John's. If this place be taken the country is ours; if we
miscarry in this, all other achievements will profit but little. I
am fearful our army may be too sickly, and that the siege may
be hard; therefore choose to assist in conquering St. John's,
which, of consequence, conquers the whole. You may rely on
it that I shall join you in about three days, with three hundred
or more Canadian volunteers. I could raise one or two
thousand in a week's time, but will first visit the army with a
less number, and if necessary will go again recruiting. Those
that used to be enemies to our cause come cap in hand to
me, and I swear by the Lord I can raise three times the
number of our army in Canada, provided you continue the
siege; all depends on that. It is the advice of the officers with
me, that I speedily repair to the army. God grant you wisdom,
fortitude and every accomplishment of a victorious general;
the eyes of all America, nay, of Europe, are or will be on the
economy of this army, and the consequences attending it. I
am your most obedient humble servant,
Ethan Allen.
P.S.—I have purchased six hogsheads of rum, and sent a
sergeant with a small party to deliver it at headquarters. Mr.
Livingston, and others under him, will provide what fresh beef
you need; as to bread and flour, I am forwarding what I can.
You may rely on my utmost attention to this object, as well as
raising auxiliaries. I know the ground is swampy and bad for
raising batteries, but pray let no object of obstructions be
insurmountable. The glory of a victory, which will be attended
with such important consequences, will crown all our fatigue,
risks, and labors; to fail of victory will be an eternal disgrace;
but to obtain it will elevate us on the wings of fame.
Yours, etc.,
Ethan Allen.

On September 17th, three and a half months after Allen urged the
invasion of Canada, Montgomery began the siege of St. John's. Two
or three days later Warner arrived with his regiment of Green
Mountain Boys. Arnold, not behind in energy and daring, captured a
British sloop.
On September 24th Allen, with about eighty men, chiefly
Canadians, met Major John Brown, with about two hundred
Americans and Canadians, and Brown proposed to attack Montreal.
It was agreed that Brown should cross the St. Lawrence that night
above the city, while Allen crossed it below. Allen added about thirty
English-Americans to his force and crossed. The cause of Brown's
failure to meet him has never been explained. Several hundred
English-Canadians and Indians with forty regular soldiers attacked
Allen, and for two hours he bravely and skilfully fought a force
several times larger than his own. Most of Allen's Canadian allies
deserted him, and with thirty of his men he was finally captured,
loaded with irons, and transported to England.
Thus, within five months, Allen, who had never before seen a
battle or an army, who had never been trained as a soldier, becomes
famous by the capture of Ticonderoga; is influential in preventing
the abandonment of Ticonderoga; is foremost in the institution of a
regiment of Green Mountain Boys; is rejected by that regiment as its
commanding officer; is successful in raising the Canadians; urges
Congress to invade Canada; fails from lack of support in his attack
on Montreal; in five short months, fame, defeat, and bitter captivity.
Warner's announcement to Montgomery is as follows:

La Prairie, September 27, 1775.


May it please your Honor, I have the disagreeable news to
write you that Colonel Allen hath met a defeat by a stronger
force which sallied out of the town of Montreal after he had
crossed the river about a mile below the town. I have no
certain knowledge as yet whether he is killed, taken, or fled;
but his defeat hath put the French people into great
consternation. They are much concerned for fear of a
company coming over against us. Furthermore the Indian
chiefs were at Montreal at the time of Allen's battle, and there
were a number of Caughnawaga Indians in the battle against
Allen, and the people are very fearful of the Indians. There
were six in here last night, I suppose sent as spies. I asked
the Indians concerning their appearing against us in every
battle; their answer to me was, that Carleton made them
drunk and drove them to it; but they said they would do so
no more. I should think it proper to keep a party at Longueil,
and my party is not big enough to divide. If I must tarry here,
I should be glad of my regiment, for my party is made up
with different companies in different regiments, and my
regulation is not as good as I could wish, for subordination to
your orders is my pleasure. I am, sir, with submission, your
humble servant,
To General Montgomery. Seth Warner.

This moment arrived from Colonel Allen's defeat, Captain


Duggan with the following intelligence: Colonel Allen is
absolutely taken captive to Montreal with a few more, and
about two or three killed, and about as many wounded. The
living are not all come in. Something of a slaughter made
among the King's troops. From yours to serve,
Seth Warner.

Schuyler, Montgomery, and Livingston, in letters written after the


defeat, comment on Allen's imprudence in making the attack single-
handed, but no mention is made of Brown, with whose force Allen
expected to be re-enforced, and with whose help the tide of battle
might have been turned and Canada's future might have been
entirely changed.
C HAPTER XI.

ALLEN'S NARRATIVE.—ATTACK ON MONTREAL.—DEFEAT AND SURRENDER.—BRUTAL


TREATMENT.—ARRIVAL IN ENGLAND.—DEBATES IN PARLIAMENT.

The story of Allen's captivity is best told in his own vivid narrative
as follows:

On the morning of the 24th day of September I set out


with my guard of about eighty men, from Longueuil, to go to
Laprairie, from whence I determined to go to General
Montgomery's camp; I had not advanced two miles before I
met with Major Brown, who has since been advanced to the
rank of a colonel, who desired me to halt, saying that he had
something of importance to communicate to me and my
confidants; upon which I halted the party and went into a
house, and took a private room with him and several of my
associates, where Colonel Brown proposed that, provided I
would return to Longueuil and procure some canoes, so as to
cross the river St. Lawrence a little north of Montreal, he
would cross it a little to the south of the town, with near two
hundred men, as he had boats sufficient, and that we could
make ourselves masters of Montreal. This plan was readily
approved by me and those in council, and in consequence of
which I returned to Longueuil, collected a few canoes, and
added about thirty English-Americans to my party and crossed
the river in the night of the 24th, agreeably to the proposed
plan.
My whole party at this time consisted of about one hundred
and ten men, near eighty of whom were Canadians. We were
most of the night crossing the river, as we had so few canoes
that they had to pass and repass three times to carry my
party across. Soon after daybreak, I set a guard between me
and the town, with special orders to let no person pass or
repass them, another guard on the other end of the road with
like directions; in the mean time, I reconnoitred the best
ground to make a defence, expecting Colonel Brown's party
was landed on the other side of the town, he having the day
before agreed to give three huzzas with his men early in the
morning, which signal I was to return, that we might each
know that both parties were landed; but the sun by this time
being nearly two hours high, and the sign failing, I began to
conclude myself to be in a præmunire, and would have
crossed the river back again, but I knew the enemy would
have discovered such an attempt; and as there could not
more than one-third part of my troops cross at a time, the
other two-thirds would of course fall into their hands. This I
could not reconcile to my own feelings as a man, much less
as an officer; I therefore concluded to maintain the ground if
possible and all to fare alike. In consequence of this
resolution, I dispatched two messengers, one to Laprairie to
Colonel Brown, and the other to L'Assomption, a French
settlement, to Mr. Walker who was in our interest, requesting
their speedy assistance, giving them at the same time to
understand my critical situation. In the mean time, sundry
persons came to my guards pretending to be friends, but
were by them taken prisoners and brought to me. These I
ordered to confinement until their friendship could be further
confirmed; for I was jealous they were spies, as they proved
to be afterward. One of the principal of them making his
escape, exposed the weakness of my party, which was the
final cause of my misfortune; for I have been since informed
that Mr. Walker, agreeably to my desire, exerted himself, and
had raised a considerable number of men for my assistance,
which brought him into difficulty afterward, but upon hearing
of my misfortune he disbanded them again.
The town of Montreal was in a great tumult. General
Carleton and the royal party made every preparation to go on
board their vessels of force, as I was afterward informed, but
the spy escaped from my guard to the town occasioned an
alteration in their policy and emboldened General Carleton to
send the force which had there collected out against me. I
had previously chosen my ground, but when I saw the
number of the enemy as they sallied out of the town I
perceived it would be a day of trouble, if not of rebuke; but I
had no chance to flee, as Montreal was situated on an island
and the St. Lawrence cut off my communication to General
Montgomery's camp. I encouraged my soldiers to bravely
defend themselves, that we should soon have help, and that
we should be able to keep the ground if no more. This and
much more I affirmed with the greatest seeming assurance,
and which in reality I thought to be in some degree probable.
The enemy consisted of not more than forty regular troops,
together with a mixed multitude, chiefly Canadians, with a
number of English who lived in town, and some Indians; in all
to the number of five hundred.
The reader will notice that most of my party were
Canadians; indeed, it was a motley parcel of soldiery which
composed both parties. However, the enemy began to attack
from wood-piles, ditches, buildings, and such like places, at a
considerable distance, and I returned the fire from a situation
more than equally advantageous. The attack began between
two and three o'clock in the afternoon, just before which I
ordered a volunteer by the name of Richard Young, with a
detachment of nine men as a flank guard, which, under the
cover of the bank of the river, could not only annoy the
enemy, but at the same time serve as a flank guard to the left
of the main body.
The fire continued for some time on both sides; and I was
confident that such a remote method of attack could not
carry the ground, provided it should be continued till night;
but near half the body of the enemy began to flank round to
my right, upon which I ordered a volunteer by the name of
John Dugan, who had lived many years in Canada and
understood the French language, to detach about fifty
Canadians, and post himself at an advantageous ditch which
was on my right, to prevent my being surrounded. He
advanced with the detachment, but instead of occupying the
post made his escape, as did likewise Mr. Young upon the left,
with their detachments. I soon perceived that the enemy was
in possession of the ground which Dugan should have
occupied. At this time I had but about forty-five men with me,
some of whom were wounded; the enemy kept closing round
me, nor was it in my power to prevent it; by which means my
situation, which was advantageous in the first part of the
attack, ceased to be so in the last; and being entirely
surrounded with such vast, unequal numbers, I ordered a
retreat, but found that those of the enemy who were of the
country, and their Indians, could run as fast as my men,
though the regulars could not. Thus I retreated near a mile,
and some of the enemy with the savages kept flanking me,
and others crowded hard in the rear. In fine, I expected in a
very short time to try the world of spirits; for I was
apprehensive that no quarter would be given to me, and
therefore had determined to sell my life as dear as I could.
One of the enemy's officers boldly pressing in the rear,
discharged his fusee at me; the ball whistled near me, as did
many others that day. I returned the salute and missed him,
as running had put us both out of breath; for I concluded we
were not frightened. I then saluted him with my tongue in a
harsh manner, and told him that inasmuch as his numbers
were so far superior to mine, I would surrender provided I
could be treated with honor and be assured of a good quarter
for myself and the men who were with me; and he answered
I should; another officer, coming up directly after, confirmed
the treaty; upon which I agreed to surrender with my party,
which then consisted of thirty-one effective men and seven
wounded. I ordered them to ground their arms, which they
did.
The officer I capitulated with then directed me and my
party to advance toward him, which was done; I handed him
my sword, and in half a minute after a savage, part of whose
head was shaved, being almost naked and painted, with
feathers intermixed with the hair of the other side of his
head, came running to me with an incredible swiftness; he
seemed to advance with more than mortal speed; as he
approached near me, his hellish visage was beyond all
description; snakes' eyes appear innocent in comparison to
his; his features distorted, malice, death, murder, and the
wrath of devils and damned spirits are the emblems of his
countenance, and in less than twelve feet of me, presented
his firelock; at the instant of his present, I twitched the officer
to whom I gave my sword between me and the savage; but
he flew round with great fury, trying to single me out to shoot
me without killing the officer, but by this time I was nearly as
nimble as he, keeping the officer in such a position that his
danger was my defence; but in less than half a minute, I was
attacked by just such another imp of hell. Then I made the
officer fly around with incredible velocity for a few seconds of
time, when I perceived a Canadian who had lost one eye, as
appeared afterward, taking my part against the savages; and
in an instant an Irishman came to my assistance with a fixed
bayonet, and drove away the fiends, swearing by —— he
would kill them. This tragic scene composed my mind. The
escaping from so awful a death made even imprisonment
happy; the more so as my conquerors on the field treated me
with great civility and politeness.
The regular officers said that they were very happy to see
Colonel Allen. I answered them that I should rather choose to
have seen them at General Montgomery's camp. The
gentlemen replied that they gave full credit to what I said,
and as I walked to the town, which was, as I should guess,
more than two miles, a British officer walking at my right
hand and one of the French noblesse at my left; the latter of
which, in the action, had his eyebrow carried away by a
glancing shot, but was nevertheless very merry and facetious,
and no abuse was offered me till I came to the barrack yard
at Montreal, where I met General Prescott, who asked me my
name, which I told him; he then asked me whether I was that
Colonel Allen who took Ticonderoga. I told him that I was the
very man; then he shook his cane over my head, calling me
many hard names, among which he frequently used the word
rebel, and put himself in a great rage. I told him he would do
well not to cane me, for I was not accustomed to it, and
shook my fist at him, telling him that was the beetle of
mortality for him if he offered to strike; upon which Captain
M'Cloud of the British, pulled him by the skirt and whispered
to him, as he afterward told me, to this import, that it was
inconsistent with his honor to strike a prisoner. He then
ordered a sergeant's command with fixed bayonets to come
forward and kill thirteen Canadians who were included in the
treaty aforesaid.
It cut me to the heart to see the Canadians in so hard a
case, in consequence of their having been true to me; they
were wringing their hands, saying their prayers, as I
concluded, and expected immediate death. I therefore
stepped between the executioners and the Canadians,
opened my clothes, and told General Prescott to thrust his
bayonet into my breast, for I was the sole cause of the
Canadians taking up arms.
The guard in the mean time, rolling their eyeballs from the
General to me, as though impatiently waiting his dread
command to sheath their bayonets in my heart; I could
however, plainly discern, that he was in a suspense and
quandary about the matter; this gave me additional hopes of
succeeding; for my design was not to die, but to save the
Canadians by a finesse. The general stood a minute, when he
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!

ebookultra.com

You might also like