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

Java Collections An Introduction to Abstract Data Types Data Structures and Algorithms 1st Edition David A. Watt all chapter instant download

Data

Uploaded by

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

Java Collections An Introduction to Abstract Data Types Data Structures and Algorithms 1st Edition David A. Watt all chapter instant download

Data

Uploaded by

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

Download the full version of the ebook at

https://ebookultra.com

Java Collections An Introduction to Abstract


Data Types Data Structures and Algorithms 1st
Edition David A. Watt

https://ebookultra.com/download/java-collections-
an-introduction-to-abstract-data-types-data-
structures-and-algorithms-1st-edition-david-a-
watt/

Explore and download more ebook at https://ebookultra.com


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

Data Structures and Algorithms in Java 4th Edition Michael


T. Goodrich

https://ebookultra.com/download/data-structures-and-algorithms-in-
java-4th-edition-michael-t-goodrich/

ebookultra.com

Data Structures and Algorithms in Java 6th Edition Michael


T. Goodrich

https://ebookultra.com/download/data-structures-and-algorithms-in-
java-6th-edition-michael-t-goodrich/

ebookultra.com

Growing Algorithms and Data Structures 4th Edition David


Scuse

https://ebookultra.com/download/growing-algorithms-and-data-
structures-4th-edition-david-scuse/

ebookultra.com

AI algorithms data structures and idioms in Prolog Lisp


and Java 6th Edition George F. Luger

https://ebookultra.com/download/ai-algorithms-data-structures-and-
idioms-in-prolog-lisp-and-java-6th-edition-george-f-luger/

ebookultra.com
Learning F Functional Data Structures and Algorithms 1st
Edition Masood

https://ebookultra.com/download/learning-f-functional-data-structures-
and-algorithms-1st-edition-masood/

ebookultra.com

Data Structures Algorithms In Go 1st Edition Hemant Jain

https://ebookultra.com/download/data-structures-algorithms-in-go-1st-
edition-hemant-jain/

ebookultra.com

Learning JavaScript Data Structures and Algorithms 2nd


Edition Loiane Groner

https://ebookultra.com/download/learning-javascript-data-structures-
and-algorithms-2nd-edition-loiane-groner/

ebookultra.com

Data Structures and Algorithms Using Python 1st Edition


Rance D. Necaise

https://ebookultra.com/download/data-structures-and-algorithms-using-
python-1st-edition-rance-d-necaise/

ebookultra.com

Concise Notes on Data Structures and Algorithms Ruby


Edition Christopher Fox

https://ebookultra.com/download/concise-notes-on-data-structures-and-
algorithms-ruby-edition-christopher-fox/

ebookultra.com
Java Collections An Introduction to Abstract Data Types
Data Structures and Algorithms 1st Edition David A.
Watt Digital Instant Download
Author(s): David A. Watt, Deryck F. Brown
ISBN(s): 9780471899785, 047189978X
Edition: 1
File Details: PDF, 15.45 MB
Year: 2001
Language: english
Java Collections
This page intentionally left blank
Java Collections
An Introduction to Abstract
Data Types, Data Structures
and Algorithms

David A. Watt
University of Glasgow

Deryck F. Brown
The Robert Gordon University

JOHN WILEY & SONS, LTD


CHICHESTER • NEW YORK • WEINHEIM • BRISBANE • SINGAPORE • TORONTO
Copyright © 2001 by John Wiley & Sons, Ltd, The Atrium, Southern Gate,
Chichester, West Sussex PO19 8SQ, England
Telephone (+44) 1243 779777

Email (for orders and customer service enquiries): [email protected]


Visit our Home Page www.wileyeurope.com or www.wiley.com

Reprinted August 2001, July 2003

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,
scanning or otherwise, except under the terms of the Copyright, Designs and Patents Act 1988 or
under the terms of a licence issued by the Copyright Licensing Agency Ltd, 90 Tottenham Court
Road, London WIT 4LP, UK, without the permission in writing of the Publisher, with the exception
of any material supplied specifically for the purpose of being entered and executed on a computer
system, for exclusive use by the purchaser of the publication.

Neither the authors) nor John Wiley & Sons, Ltd accept any responsibility or liability for loss or
damage occasioned to any person or property through using the material, instructions, methods or
ideas contained herein, or acting or refraining from acting as a result of such use. The authors)
and Publisher expressly disclaim all implied warranties, including merchantability of fitness for
any particular purpose.

Designations used by companies to distinguish their products are often claimed as trademarks. In all
instances where John Wiley & Sons Ltd is aware of a claim, the product names appear in initial capital
or capital letters. Readers, however, should contact the appropriate companies for more complete
information regarding trademarks and registration.

Other Wiley Editorial Offices

John Wiley & Sons Inc., 111 River Street, Hoboken, NJ 07030, USA

Jossey-Bass, 989 Market Street, San Francisco, CA 94103–1741, USA

Wiley-VCH Verlag GmbH, Boschstr. 12, D-69469 Weinheim, Germany

John Wiley & Sons Australia Ltd, 33 Park Road, Milton, Queensland 4064, Australia

John Wiley & Sons (Asia) Pte Ltd, 2 dementi Loop #02-01, Jin Xing Distripark, Singapore 129809

John Wiley & Sons (Canada) Ltd, 22 Worcester Road, Etobicoke, Ontario M9W 1L1

Wiley also publishes its books in a variety of electronic formats. Some content that appears in print
may not be available in electronic books.

British Library Cataloguing in Publication Data

A catalogue record for this book is available from the British Library

ISBN 0471 89978 X

Cover Image — Fondaco dei Turchi, Venice (w/c) by John Ruskin (1819–1900)
Ruskin Museum, Coniston, Cumbria, UK/Bridgeman Art Library

Printed and bound in Great Britain by Biddies Ltd, Guildford and King's Lynn
This book is printed on acid-free paper responsibly manufactured from sustainable forestry
in which at least two trees are planted for each one used for paper production.
Contents

Preface xi

1 Introduction i
I. I Historical background I
1.2 Algorithms and programs 6
1.3 Abstract data types and data structures 7
Summary 9
Exercises 9

2 Algorithms 11
2.1 Principles of algorithms 1 I
2.2 Efficiency of algorithms )4
2.3 Complexity of algorithms i7
2.4 Recursive algorithms 24
Summary 31
Exercises 3i

3 The Array Data Structure 34


3.1 Arrays 34
3.2 Insertion 38
3.3 Deletion 39
3.4 Searching 40
3.5 Merging 46
3.6 Sorting 49
Summary 62
Exercises 62

4 Linked-List Data Structures 67


4.1 Linked lists 67
4.2 Insertion 78
vi Contents

4.3 Deletion 81
4.4 Searching 86
4.5 Merging 88
4.6 Sorting 91
Summary 94
Exercises 95

5 Abstract Data Types 97


5.1 Datatypes 97
5.2 Abstract data types 103
5.3 Abstract data type design 111
5.4 String abstract data types 114
5.5 Collection abstract data types 120
5.6 Abstract data types in the Java class library 120
Summary 122
Exercises 123

6 Stack Abstract Data Types 125


6.1 The concept of a stack 125
6.2 Applications of stacks 125
6.3 A stack abstract data type 129
6.4 Implementation of bounded stacks using arrays I 30
6.5 Implementation of unbounded stacks using linked lists 132
6.6 Case study: solving and generating mazes 135
Summary 146
Exercises 146

7 Queue Abstract Data Types 149


7.1 The concept of a queue 149
7.2 Applications of queues 149
7.3 A queue abstract data type 151
7.4 Implementation of bounded queues using arrays 152
7.5 Implementation of unbounded queues using linked lists 156
7.6 Case study: a traffic simulator 157
Summary 166
Exercises 167

8 List Abstract Data Types 170


8.1 The concept of a list 170
8.2 Applications of lists 171
8.3 A list abstract data type 172
8.4 Iterators 175
8.5 Implementation of bounded lists using arrays 179
8.6 Implementation of unbounded lists using linked lists 185
8.7 Lists in the Java class library 191
8.8 Case study: a videotape manager
Summary
Exercises

9 Set Abstract Data Types


9.1 The concept of a set
9.2 Applications of sets
9.3 A set abstract data type
9.4 Implementation of bounded sets using arrays
9.5 Implementation of unbounded sets using linked lists
9.6 Implementation of small-integer sets using boolean arrays
9.7 Sets in the Java class library
9.8 Case study: an interactive spell-checker
Summary
Exercises

10 Binary Tree Data Structures 236


10.1 Binary trees 236
10.2 Searching 242
10.3 Insertion 245
10.4 Deletion 247
10.5 Traversal 256
10.6 Merging 26!
10.7 Implementation of unbounded sets using binary search trees 262
Summary 270
Exercises 270

11 Map Abstract Data Types 274


11.1 The concept of a map 274
11.2 Applications of maps 276
I11.3 A map abstract data type 277
I 1.4 Implementation of small-integer-key maps using key-indexed arrays 281
11.5Implementation of bounded maps using arrays 283
11.6Implementation of unbounded maps using linked lists 287
11.7Implementation of unbounded maps using binary search trees 288
11.8Maps in the Java class library 290
11.9 Case study: a student record system 293
Summary 303
Exercises 304

12 Hash-Table Data Structures 307


12.1 Hash tables 307
12.2 Closed-bucket hash tables 309
12.3 Open-bucket hash tables 316
12.4 Implementations of sets using hash tables 331
viii Contents

12.5 Implementations of maps using hash tables 332


Summary 334
Exercises 334

13 Priority-Queue Abstract Data Types 337


I 3.1 The concept of a priority queue 337
13.2 Applications of priority queues 338
13.3 A priority-queue abstract data type 339
13.4 Implementations of priority queues using linked lists 341
13.5 The heap data structure 344
13.6 Implementation of priority queues using heaps 355
I 3.7 Case study: an improved traffic simulator 355
Summary 361
Exercises 363

14 Tree Abstract Data Types 366


14.1 The concept of a tree 366
14.2 Applications of trees 367
14.3 A tree abstract data type 369
14.4 A linked implementation of trees 369
14.5 Specialized tree abstract data types 378
14.6 Case study: game playing 381
Summary 394
Exercises 395

15 Graph Abstract Data Types 397


15.1 The concept of a graph 397
15.2 Applications of graphs 399
15.3 Graph abstract data types 400
15.4 Edge-set representation of graphs 403
15.5 Adjacency-set representation of graphs 408
15.6 Adjacency-matnx representation of graphs 413
15.7 Graph traversal 415
15.8 Topological sort 420
15.9 Case study: material requirements planning 422
Summary 431
Exercises 431

16 Balanced Search Tree Data Structures 435


16.1 AVL-trees 435
16.2 B-trees 447
Summary 466
Exercises 467
17 Conclusion 469
17.1 Abstract data types and object-oriented design 469
17.2 Abstract data types as reusable software components 47!
17.3 Homogeneous and heterogeneous collections 472
i 7.4 Extending Java with parameterized classes 476
17.5 Case study: a student record system revisited 477
Summary 482
Exercises 482

A Summary of Mathematics for Algorithm Analysis 484


A.I Powers 484
A.2 Logarithms 486
A3 Series summations 487
A,4 Recurrences 488
A.5 O-notation 490

B Summary of Java 495


B.I Basics 495
B.2 Classes
B.3 Interfaces
B.4 Packages
B.5 Exceptions
B.6 Inner classes and inner interfaces

C Summary of the Java Collections Framework 5) 7


C.I Collections 517
C.2 Lists 520
C.3 Sets 524
C.4 Maps 528
C.5 Orderings 533
C.6 Iterators 534

Further reading 537


Bibliographic notes 537
Bibliography 539

Index 540
This page intentionally left blank
Preface

This book has four major themes: algorithms, data structures, abstract data types
(ADTs), and object-oriented methods. All of these themes are of central importance in
computer science and software engineering.
The book focuses on a number of important ADTs - stacks, queues, lists (sequences),
sets, maps (tables), priority queues, trees, and graphs - that turn up again and again in
software engineering. It uses these ADTs to motivate the data structures required to
implement them - arrays, linked lists, search trees, hash tables, and heaps - and algo-
rithms associated with these data structures - insertion, deletion, searching, merging,
sorting, and traversal. The book shows how to implement these data structures and
algorithms in the object-oriented programming language Java.
The book's typical approach is to introduce an ADT, illustrate its use by one or two
example applications, develop a 'contract' specifying the ADT's values and operations,
and finally consider which data structures are suitable for implementing the ADT. This
approach clearly distinguishes between applications and implementations of the ADT,
thus reinforcing a key software engineering principle: separation of concerns. The book
motivates the study of data structures and algorithms by introducing them on a need-to-
know basis. In other words, it adopts a practical (software engineering) approach to the
subject, rather than a theoretical one. It does not neglect the important topic of algorithm
analysis, but emphasizes its practical importance rather than the underlying mathematics.
Object-oriented methods have emerged as the dominant software technology during
the last decade, and Java has become the dominant programming language in computer
science education. These developments call for a fresh approach to the teaching of
programming and software engineering. This book takes such a fresh approach, using
object-oriented methods from the outset to design and implement ADTs. It avoids the
mistake of reworking an older book on algorithms and data structures that was written
originally for Pascal or C.
Several of the ADTs introduced in this book are directly supported by the Java 2
collection classes. Programmers will naturally prefer to use these collection classes rather
than design and implement their own. Nevertheless, choosing the right collection classes
for each application requires an understanding of the properties of different ADTs and
XI
xii Preface

their alternative implementations. This book aims to give readers the necessary under-
standing.

Readership
This book can be read by anyone who has taken a first programming course in Java.
The book is designed primarily as a text for a second-level course in algorithms and
data structures, in the context of a computer science program in which Java is the main
programming language. In terms of the 1991 and 2001 ACM Computing Curricula, the
book covers the knowledge units summarized in Table P. 1.
The book is also suitable for practicing software engineers who have just learned Java
and who now wish to gain (or refresh) the knowledge of algorithms and data structures
required to make effective use of the Java 2 collection classes.
The detailed prerequisites of this book are as follows:
• A knowledge of fundamental Java programming topics - expressions, statements,
objects, and classes - is essential. A knowledge of more advanced topics - inheritance,
exceptions, interfaces, inner classes - is desirable but not essential before reading this
book. Readers unfamiliar with the latter topics should refer to Appendix B whenever
necessary.
• Certain mathematical topics - powers, logarithms, series summations, and recurrences
- are needed to analyze the efficiency of algorithms. Most of these mathematical topics
are taught in secondary/high schools. Readers unfamiliar with any of these topics
should refer to Appendix A whenever necessary.

Outline
Chapter 1 introduces two of this book's major themes: algorithms and data structures.
Chapter 2 takes a closer look at algorithms, showing how we can analyze their efficiency
and introducing recursive algorithms.
Chapters 3 and 4 review two simple and ubiquitous data structures - arrays and linked
lists - together with their associated insertion, deletion, searching, merging, and sorting
algorithms. Later in the book, Chapters 10, 12, 13, and 16 introduce more sophisticated

Table P.1 Coverage of ACM Computing Curricula knowledge units.

ACM/IEEE Computing Curricula 2001 ACM/IEEE Computing Curricula 1991

PF1 (algorithms and problem-solving) AL1 (basic data structures)


PF3 (basic data structures) AL2 (abstract data types)
PF4 (recursion) AL3 (recursive algorithms)
PF5 (abstract data types) AL4 (complexity analysis)
AL1 (basic algorithmic analysis) AL6 (sorting and searching)
AL3 (fundamental computing algorithms)
Preface

data structures - binary search trees, hash tables, heaps, AVL-trees, and B-trees - again
together with their associated algorithms.
Chapter 5 takes a close look at the idea of an abstract data type (ADT). It introduces the
notion of a 'contract' that specifies the values and operations of an ADT without commit-
ting to a particular representation. Chapters 6 (stacks), 7 (queues), 8 (lists), 9 (sets), 11
(maps), 13 (priority queues), 14 (trees), and 15 (graphs) introduce a variety of collection
ADTs together with alternative implementations of each. The list, set, and map ADTs
covered in Chapters 8,9, and 11 are in fact simplified versions of the corresponding Java
2 collection classes.
Chapter 17 concludes the book. It discusses the role of ADTs in object-oriented design.
It also discusses the distinction between heterogeneous and homogeneous collections,
and an extension of Java that supports generic homogeneous collections.
Appendix A summarizes the mathematical topics needed to analyze the efficiency of
algorithms. Appendix B summarizes the features of Java that are most important in this
book, particularly the more advanced features that are likely to be omitted in a first
programming course. Appendix C summarizes the Java 2 collection classes.
Ideally, all the chapters of this book should be read in numerical order. Figure P.2
summarizes the dependencies between chapters. Clearly, Chapters 1-5 must be read first,
and Chapters 6-9 all rely on this introductory material. Chapter 10 depends on Chapters 6
and 9, and in turn Chapters 11,13 and 16 all depend on Chapter 10. Readers may vary the
order of some of the later chapters, as indicated by Figure P.2. Readers may also omit any
of Chapters 13–17 if time is short.

1 Introduction

2 Algorithms

3 Arrays 4 Linked Lists 5 ADTs

6 Stack ADTs 7 Queue ADTs 8 List ADTs 9 Set ADTs

10 Binary Trees

13 Priority 14 Tree ADTs


Queue ADTs
16 Balanced 12 Hash Tables 15 Graph ADTs
Search Trees
17 Conclusion

Figure P.2 Dependencies between chapters.


xiv Preface

Scope
This book is an introductory text. As such, it covers several topics, such as algorithm
complexity, hash tables, and graphs, in rather less depth than would be possible
in a more advanced text. Moreover, it omits altogether a variety of interesting algo-
rithms, such as compression, encryption, geometric, linear algebra, and scheduling
algorithms.
Under Further Reading there is a list of books that do cover these more advanced
topics, together with seminal papers on topics covered by this book. There are also
bibliographic notes that suggest further reading on the topics covered by each chapter
and by the book as a whole.

Java Collections framework


The Java 2 software development kit (SDK) provides a library of classes supporting the
most common ADTs: lists, sets, and maps. These are known collectively as the Java
collection classes, and they fit together in what is called the Java Collections framework.
Programmers should use these collection classes rather than designing and implementing
their own. However, the framework is complex and incomplete, and selecting the correct
collection class for a given problem is not always easy.
This book aims to help programmers in the following ways:
• To reduce complexity, we introduce our own contract for each ADT. Our contract
captures the fundamental properties of the ADT, and is not biased towards a particular
implementation.
• To maintain compatibility, our ADT contract is always a simplified version of the
contract of the corresponding Java collection class (if any). The applications presented
in this book can all be trivially modified to use the corresponding collection classes.
(The only necessary changes are to import the java.util package and to modify
certain constructor invocations.)
• To guide the selection of the appropriate ADT for a given problem, we present one or
more short examples, and a case study, illustrating how to use each ADT.
• To guide the selection of the most appropriate implementation of an ADT, we analyze
the efficiency of several alternative implementations, and compare them with the
corresponding Java collection class (if any).
• In addition to the list, set, and map ADTs supported by the Java Collections frame-
work, we also cover other important ADTs: stacks, queues, priority queues, trees, and
graphs. Our contracts for these ADTs follow the same style as the Java Collections
framework, so readers should be able to adapt easily.

Companion Web site


This book is complemented by a Web site, whose URL is
www.wiley.co.uk/watthrown
Preface xv

This Web site contains the book's contents and preface, answers to selected exercises,
and Java code for all ADTs and case studies. New features will be added from time to
time.

Case studies
Case studies are an important feature of this book. They can be found in Chapters 6–9,11,
13-15, and 17.
Each case study leads the reader through the object-oriented design and implementa-
tion of a fair-sized application program. The presentation focuses on the selection of an
ADT appropriate for the application, and later on the choice of the most suitable imple-
mentation of that ADT (from among those presented earlier in the chapter). The object-
oriented design of the application program itself, and the development of algorithms to be
employed by the application program, are also discussed. User interface issues are
generally omitted here, however.
Complete Java source code for all case studies may be found at the companion Web
site. For some case studies, there is an application program that can be downloaded and
run. For others, there is an applet that can be run immediately using a Java-enabled Web
browser. Where appropriate, each case study comes in two versions, one using the classes
developed in this book and the other using the Java collection classes.

Exercises
Each chapter is followed by a set of exercises. Some of these exercises are drill, or simple
modifications to designs, algorithms, or implementations presented in the chapter. The
more challenging exercises are clearly marked as * (hard) or ** (harder).
Sample answers to selected exercises can be found at the companion Web site.

About the authors


David Watt is a frofessor of Computing Science at the University of Glasgow. He has 26
years' experience of teaching undergraduates and graduates, in programming, algo-
rithms, data structures, software engineering, and other topics. He developed the material
of Chapters 1–12 for a course in algorithms and data structures, first taught in early 1999.
His research interests are design, specification, and implementation of programming
languages.
Deryck Brown is a Senior Lecturer in Computing Science at the Robert Gordon
University, Aberdeen. He has 6 years' experience of teaching undergraduates and grad-
uates, in object-oriented programming, software engineering, and several other topics.
His research interests are specification and implementation of programming languages,
and genetic algorithms.
xvi Preface

Acknowledgements
Most of the algorithms and data structures described in this textbook have long since
passed into computer science folklore, and are almost impossible to attribute to indivi-
duals. Instead, we acknowledge those colleagues who have particularly influenced us
through discussions on the topics of this book: David Davidson, Rob Irving, Alistair
Kilgour, John McCall, and Joe Morris. We wish to thank the Wiley reviewers for reading
and providing valuable comments on an earlier draft of this book. In addition, we would
like to thank William Teahan for his extensive and detailed comments. Finally, we are
delighted to acknowledge the assistance of the staff at John Wiley & Sons, particularly
our editors Gaynor Redvers-Mutton and Gemma Quilter.

David A. Watt
Glasgow

Deryck F. Brown
Aberdeen

August 2000
1
Introduction

In this chapter we shall study:


• several simple algorithms, set in a historical context (Section I.I)
• the relationship between algorithms and programs (Section 1.2)
• static and dynamic data structures, and the concept of an abstract data type
(Section 1.3).

1.1 Historical background


Algorithms are procedures for solving stated problems. A very simple example is the
problem of multiplying two numbers. Multiplying small numbers such as 7 and 9 is
trivial, because we can memorize the answers in advance. But to multiply larger numbers
such as 1234 and 789 we need a step-by-step procedure, or algorithm. We all learn such
an algorithm in school, using long multiplication or logarithms. (Even if we make an
electronic calculator do the work, the calculator uses its own multiplication algorithm.)
Algorithms and computation have a long history, perhaps as long as civilization itself.
The achievements of the ancient civilizations of China, Egypt, India, and Mesopotamia
leave us in no doubt that their architects, astronomers, engineers, and merchants knew
how to perform the computations associated with their professions. Unfortunately we
have only fragmentary and indirect knowledge of the algorithms developed by these very
ancient civilizations.
(Note: Much of the historical information in this chapter was culled from an excellent
Web site at the University of St Andrews: www-history .mcs . st - and. ac . uk/
history/.)
The scholars of the Hellenic civilization systematized many of the achievements of
their predecessors, and added enormous contributions of their own. Athens, Alexandria,
and other Hellenic cities contained 'academies' where scholars worked and taught
together - forerunners of modern universities. Scholars such as Euclid (about 325-265
BCE) and Eratosthenes (276-194 BCE), discovered or perfected a variety of algorithms
that are still used today.
lava Collections

To find the midpoint of a straight line segment AB:


1. Draw intersecting circles of equal radius centered at points A and B.
2. Let C and D be the two points where the circles intersect.
3. Draw the straight line CD.
4. Let E be the point where AB intersects CD.
5. Terminate with point E as the answer.

Algorithm 1.1 Finding the midpoint of a straight line segment.

B
Initially:

After step 2:

After step 4:

Figure 1.2 Illustration of Algorithm 1.1.

EXAMPLE 1.1 Finding the midpoint of a straight line segment


The Hellenic mathematicians systematically studied two- and three-dimensional geome-
try, motivated by their interests in architecture, astronomy, and geography. Algorithm
1.1 shows a simple geometric construction for finding the midpoint of a given straight
line. It consists of several steps, which must be performed one after the other in the order
shown. Figure 1.2 illustrates the construction, which needs only simple drawing instru-
ments: a compass (step 1) and a ruler (step 3).
introduction

To find the GCD of positive integers m and n:


1. Set p to m, and set q to n.
2. Until q exactly divides p, repeat:
2.1. Set p to q, and set q to (p modulo q).
3. Terminate with answer q,

Algorithm 1.3 Euclid's algorithm.

To solve the equation x2 + bx = c (where b and c are known positive numbers):


1. Multiply b/2 by itself.
2. Add c to the product.
3. Take the square root of the sum.
4. Let r be the difference of the square root and b/2.
5. Terminate with answer r.

Algorithm 1.4 One of al Khwarizmi's algebraic algorithms.

EXAMPLE 1.2 Computing a greatest common divisor

The greatest common divisor (GCD) of two positive integers is the largest positive
integer that exactly divides both of them. Euclid gave his name to an elegant and efficient
algorithm to solve this problem.
Euclid's algorithm is paraphrased as Algorithm 1.3. Note that (p modulo q) is the
remainder when we divide p by q.
Step 2 controls a loop. The subsidiary step 2.1 is performed repeatedly until the stated
condition arises, i.e., until q exactly divides p.

The Arabic civilization produced a world-renowned center of learning in Baghdad,


which drew on the work of Hellenic, Hebrew, and Indian scholars. Muhammad abu Ja'far
ibn Musa al Khwarizmi (about 780–850 CE) perfected the Hindu-Arabic decimal system
of numbering, which is now universal. He published a famous series of books on algebra,
geometry, and astronomy. These books were not just scholarly works, but collections of
algorithms for practical use by astronomers, engineers, surveyors, merchants, and the
like. In due course these books reached Europe, via Spain, where they were translated
into Latin. The name al Khwarizmi, translated into Latin as Algorithmus, has given us the
modern word algorithm.

EXAMPLE 1.3 Solving quadratic equations

Al Khwarizmi presented a group of algorithms to solve various quadratic equations


(equations involving x2, where x is unknown), each accompanied by a simple geometric
proof of correctness. Algorithm 1.4 paraphrases one of al Khwarizmi's algorithms. (You
might recognize the problem as a special case of the general quadratic equation.)
lava Collections

To multiply positive numbers y and z:


1. Convert y and z to their logarithms, log y and log z.
2. Let / be the sum of log y and log z.
3. Let x be the number such that log x = l.
4. Terminate with answer x.

Algorithm 1.5 Multiplication using logarithms.

Our story now moves to Europe. The Scots scholar John Napier (1550–1617), obser-
ving that computations involving multiplication, division, powers, and roots were slow
and error-prone, invented logarithms. The logarithm of a number y is the number of times
that 10 must be multiplied by itself to give y; thus log1010 = 1, log10100 = 2 (since
102 = 100), log101000 = 3 (since 103 = 1000), and so on. Intermediate numbers have
fractional logarithms; thus log!052 = 1.716, accurate to 3 decimal places.

EXAMPLE 1.4 Multiplication using logarithms

The basic law of logarithms is:


log(y x z) = logy + logz
This leads directly to a multiplication algorithm: see Algorithm 1.5.
This algorithm is faster and less error-prone than the long multiplication algorithm. A
number can be quickly converted to a logarithm (step 1) or from a logarithm (step 3) by
looking up a table of logarithms.

Logarithms (and their mechanical equivalents, slide rules) quickly became essential
tools for scientists, engineers, astronomers, and everyone else who had to do complex
calculations. They continued to be used routinely until they were superseded by electro-
nic calculators and computers in the 1960s.
The English mathematician and scientist, Isaac Newton (1643–1727), invented the
differential calculus. This gave us algorithms for differentiation (determining the slope of
a given curve) and integration (determining the area under a given curve). Differential
calculus became a keystone of mathematics and physics, and has found a vast array of
applications in engineering, weather forecasting, economics, and so on.

EXAMPLE 1.5 Computing a square root


Computing the square root of a positive number a is equivalent to finding the side of a
square whose area is a. Algorithms for computing square roots approximately have been
known since ancient times, but Newton's algorithm is preferred in modern computation.
Newton's algorithm is a by-product of differential calculus, but can be understood
intuitively. If we know two different numbers whose product is a, then we can be sure
that the square root of a lies somewhere between them; moreover, the mean of these two
numbers is a better approximation to the square root than either of the original two
numbers. For example, neither 2 nor 3 is a good approximation to the square root of
6, but their mean 2.5 is better, and the mean of 2.5 and 2.4 is even better. (The square root
of 6 is in fact 2.4495, accurate to 4 decimal places.)
In step 2.1 of Algorithm 1.6, the two numbers whose product is a are r and a/r. Their
mean is a better approximation to the square root of a, so we replace r with this mean. We
do this repeatedly, stopping only when we are satisfied that r is sufficiently close to the
desired answer. (We can check this by comparing r2 with a.)
The 17th century saw the development of the first mechanical calculators by Wilhelm
Schickard (1592–1635), Blaise Pascal (1623–62), and Gottfried Leibniz (1646–1716),
The abacus (known since ancient times), the slide rule, mechanical calculators, and
even electronic calculators are just tools that aid us humans to perform algorithms.
Among the outstanding achievements of the modern era has been the development of
machines capable of performing algorithms automatically.
The first such achievement was in a very different domain from computation. Weaving
patterns consist of steps that must be followed exactly, over and over again. For humans,
this makes weaving very tedious. The French textile manufacturer Joseph Jacquard
(1752–1834) invented an automatic loom that is driven by a pattern encoded on punched
cards. In a very real sense, a weaving pattern is an algorithm, and that algorithm is
performed by the Jacquard loom.
Returning to computation, the British mathematician Charles Babbage (1791–1871)
designed what we would now recognize as a digital computer. His assistant Ada Lovelace
(1815-52) is generally recognized to have been the first computer programmer. Unfortu-
nately, Babbage's computer could not actually be built, given the relatively primitive
technology of his time.
In the 20th century, the British mathematician Alan Turing (1912–54) studied the very
nature of computation. He came up with the remarkable result that there exist problems
for which no algorithm exists. For example, no algorithm exists that can prove an
arbitrary given theorem in logic. And no algorithm exists that can prove that an arbitrary
given computer program is correct or incorrect.
During the Second World War, Turing led a team that discovered how to break the
Enigma codes, which the Germans used for encrypting military radio messages.
However, their code-breaking algorithm relied on an exhaustive search, which would
have been extremely time-consuming, especially since the Germans changed their codes

To compute approximately the square root of a positive real number a:


1. Set r to the mean of 1 and a.
2. Until r2 is a sufficient good approximation to a, repeat:
2.1. Set r to the mean of r and a/r.
3. Terminate with answer r.
Algorithm 1.6 Newton's algorithm.
Java Collections

every day. So the team proceeded to build and use a machine, Colossus, that could break
the codes hundreds of times faster than mere humans.
The first general-purpose digital computers were built in the USA and Great Britain.
You are probably familiar with the story of computers since then. Computers are now
ubiquitous, whether as general-purpose computers or as components embedded in
devices as diverse as digital watches, kitchen appliances, and aircraft. And every one
of these computers is a machine designed to perform algorithms.
We are also surrounded by algorithms intended for performance by humans. Whether
or not a device has a computer inside it, it probably comes with a user's manual. Such
manuals contain algorithms necessary for us to use the devices effectively: to operate a
washing machine, to set a digital watch to give an alarm signal or to record lap times, to
change a car wheel, to change a light bulb, to assemble a piece of furniture from a flat-
pack, and so on.

1.2 Algorithms and programs


So what exactly is an algorithm? We shall attempt a precise definition in Chapter 2. For
the time being, we can think of an algorithm as a step-by-step procedure for solving a
stated problem. An algorithm may be intended to be performed by a human or a machine.
In either case, the algorithm must be broken down into steps that are simple enough to be
performed by the human or machine.
Algorithms have many things in common with programs, but there are also important
differences between them.
Firstly, algorithms are more general than programs. An algorithm may be suitable to
be performed by a human, or by a machine, or by both. A program must be capable of
being performed by a (suitable) machine. In this book, the machine will always be a
general-purpose computer (as opposed to a robot or weaving machine, for example).
Secondly, algorithms are more abstract than programs. An algorithm can be expressed
in any convenient language or notation. A program must be expressed in some program-
ming language. If an algorithm is intended to be performed by a computer, it must first be
coded in a programming language. There may be many ways of coding the algorithm and
there is a wide choice of programming languages. Nevertheless, all the resulting
programs are implementations of the same underlying algorithm. For example. Programs
1.7 and 1.8 are both implementations of Euclid's algorithm, coded in two different
programming languages: compare them with Algorithm 1.3.
In this book we will express algorithms in English, and code them as methods in Java.
The very same algorithms could be (and undoubtedly have been) equally well expressed
in French or Chinese, and coded in C or Pascal or Ada. The point is that we can study
these algorithms without paying too much attention to the language in which they are
expressed.
Often there exist several different algorithms that solve the same problem. We are
naturally interested in comparing such alternative algorithms. Which is fastest? Which
needs least memory? Fortunately, we can answer such questions in terms of the qualities
of the algorithms themselves, without being distracted by the languages in which they
happen to be expressed. We shall study algorithm efficiency in Chapter 2.
Introduction

static int gcd (int m, int n) {


/ / Return the GCD of positive integers m and n.
int p = m, q = n;
while (p % q != 0) {
int r = p % q;
p = q; q = r;

return q;

Program 1.7 Implementation of Euclid's algorithm as a Java method.

function gcd {m, n: Positive) return Positive is


- - Return the GCD of positive integers m and n.
p, q, r: Natural;
begin
p : = m; q : = n ;
while p mod q /= 0 loop
r := p mod q;
p := q; q := r;
end loop;
return q;
end gcd;

Program 1.8 Implementation of Euclid's algorithm as an Ada function.

1.3 Abstract data types and data structures


Complementary to the study of algorithms, and also a major theme of this book, is the
study of data structures and abstract data types.
A data structure is a systematic way of organizing a collection of data. A familiar
example of a data structure is the array, which you should have met in your first program-
ming course. The array is sometimes called a static data structure, because its data
capacity is fixed at the time it is created. This book will introduce the more flexible
dynamic data structures, which are so called because they can freely expand and contract
in accordance with the actual amount of data to be stored.
Every data structure needs a variety of algorithms for processing the data contained in
it: algorithms for insertion, deletion, searching, and so on. In this book we shall study data
structures and algorithms in conjunction.
Often there exist several data structures suitable for representing the same collection of
data. Figure 1.9 illustrates this point by showing a character string represented by two
different data structures. Figure 1.10 illustrates the point further by showing a set of
words represented by three different data structures. We shall explore all these data
structures in later chapters.
lava Collections

Figure 1.9 Representation of the character string "Java" using: (a) an array, (b) a linked list.

(a) I hat [ cat [ mat | rat | sat

Figure 1.10 Representation of the word set {bat, cat, mat. rat. sat) using: (a) an array. (b) a singly
linked list, (c) a binary search tree.

Of course, when you wish to write a Java program that manipulates character strings,
you neither know nor care how strings are represented. You simply declare variables of
type String, and manipulate them by calling methods provided by the Java. lang.
String class. String is a simple example of what we call an abstract data type. You
are told the name of the abstract data type, and the general properties of objects of that
type, and the names of methods for manipulating these objects. But you are not told how
these objects are represented.
Once an abstract data type has been designed, the programmer responsible for imple-
menting that type is concerned only with choosing a suitable data structure and coding up
the methods (without worrying much about the type's future applications). On the other
hand, application programmers are concerned only with using that type and calling its
methods (without worrying much about how the type is implemented).
This separation of concerns is a fundamental principle of modular software design. An
object-oriented programming language typically provides a rich library of predefined
abstract data types (classes), but the idea of an abstract data type goes well beyond that.
When an application program is being designed, a major part of the designer's job is to
identify abstract data types specialized to the requirements of the particular application.
A large application program might require tens or even hundreds of abstract data types.
Their identification by the designer helps to decompose the program into manageably-
sized modules that can be specified, coded, tested, and debugged separately. Such decom-
position is essential for successful software development.
Summary
in this chapter:
• We have introduced the idea of an algorithm, illustrating the idea with a variety of
algorithms of historical interest, and distinguishing between algorithms and programs.
• We have introduced the idea of a data structure, distinguishing between static and
dynamic data structures.
• We have introduced the idea of an abstract data type, distinguishing between the
separate concerns of the programmer who implements an abstract data type and the
programmers who use it.
In Chapters 2 and 5 we shall study algorithm and abstract data type concepts in greater
detail. In other chapters, we shall study a variety of data structures in conjunction with
the algorithms that operate on them, and we shall study a variety of abstract data types
showing which data structures can be used to implement them.

Exercises
1.1 Use Euclid's algorithm, given in Algorithm 1.3, to find the GCD of the following pairs of
numbers: 6 and 9, 12 and 18, 15 and 21, and 11 and 15.
1.2 Consider Newton's algorithm, given in Algorithm 1.6, to calculate the square root of a
number.
(a) Use this algorithm to calculate the square roots of the following numbers: 4, 6, 8 and 9. In
each case calculate your answer to an accuracy of 0.01, i.e., the absolute difference
between a and r2 is less than 0.01.
(b) Write a Java program to implement the algorithm and use it to check your answers to part
(a) above.
(c) What would happen if step 2 of the algorithm were as follows?
2. Until r2=a, repeat:
1.3 Give some examples of algorithms used in everyday life, not requiring a calculator or
computer.
1.4 Write an algorithm to perform each of the following tasks:
(a) Use an automated bank teller to withdraw cash from your account.
(b) Set the current time on your watch.
(c) Cook a frozen meal in a microwave oven.
(d) Match the pairs of socks in a bundle of freshly laundered socks.
1.5 Try to find further examples of early algorithms like the ones given in this chapter.
1.6 Devise an algorithm, similar to Algorithm 1.4, to find the roots of the general quadratic
equation ax2 + bx + c = 0. The roots are the two values of the formula (–b ± /(b2–4ac)V2a.
1.7 Consider the algorithms you wrote in Exercise 1.4. How easy would it be for each of these
algorithms to be performed by a human? by a suitable machine?
10 Java Collections

1.8 Consult the documentation for your Java development environment for the list of predefined
classes (or consult the on-line documentation at Java, sun.com/products/jdk/1. 3/
docs/api/index.html). Consider some of the classes provided from the point of view
of abstract data types, and determine the list of operations provided for each class.
2
Algorithms

In this chapter we shall study:


• fundamental principles of algorithms: problems that can or cannot be solved by algo-
rithms, properties of algorithms themselves, and notation for algorithms (Section 2.1)
• analysis of algorithms to determine their time and space efficiency (Section 2.2)
• the notion of complexity of algorithms (Section 2.3)
• recursive algorithms and their complexity (Section 2.4).

2.1 Principles of algorithms


In Section 1.1 we encountered a variety of algorithms. In this section we briefly discuss
some fundamental issues concerned with problems, algorithms, and notation.

Problems
Concerning problems, we can state the following principles:
• An algorithm must be designed to solve a stated problem, which is a well-defined task
that has to be performed.
• The problem must be solvable by an algorithm.
We have already (in Section 1.1) encountered a number of problems that can be solved
by algorithms. We can also pose some problems that are not solvable by algorithms. To
say that a problem is unsolvable does not just mean that an algorithm has not yet been
found to solve it. It means that such an algorithm can never be found. A human might
eventually solve the problem, but only by applying insight and creativity, not by follow-
ing a step-by-step procedure; moreover, there can be no guarantee that a solution will be
found. Here is an example of a problem that is unsolvable by an algorithm.

II
12

EXAMPLE 2.1 The halting problem

The problem is to predict whether a given computer program, with given input data, will
eventually halt.
This is a very practical problem for us programmers: we all occasionally write a
program that gets into a never-ending loop. One of the most famous results in computer
science is that this problem cannot be solved by any algorithm. It turns out that any
'algorithm' that purports to solve this problem will itself get into a never-ending loop. for
at least some programs that might be given to it. As we shall see later in this section. we
insist that every algorithm must eventually terminate.
If we can never find an algorithm to predict whether a given program halts with given
input data, we clearly can never find an algorithm to prove whether a given program
behaves correctly for all possible input data.
It may still be possible for a human to prove that a particular program is correct.
Indeed, this has been done for some important small programs and subprograms. But we
can never automate such proofs of correctness.

In fact, many problems in mathematics and computer science are unsolvable by algo-
rithms. In a way, this is rather reassuring: we can be sure that mathematicians and
computer scientists will never be made redundant by machines!
From now on, we shall consider only problems that are solvable by algorithms.

Algorithms
Concerning algorithms themselves, we can state the following principles:
• The algorithm will be performed by some processor, which may be a machine or a
human.
• The algorithm must be expressed in steps that the processor is capable of performing.
• The algorithm must eventually terminate, producing the required answer.
Some algorithms, as we have already seen, are intended to be performed by humans
rather than machines. But no algorithm is allowed to rely on qualities, such as insight and
creativity, that distinguish humans from machines. This suggests a definition:

An algorithm is an automatic procedure for solving a stated problem, a procedure that


could (at least in principle) be performed by a machine.

The principle that the algorithm must be expressed in steps that can be performed by
the processor should now be clear. If the processor has to work out for itself what steps to
follow, then what we have is not an algorithm.
The principle that every algorithm must eventually terminate should also be clear. If it
never terminates, it never produces an answer, therefore it is not an algorithm! So an
algorithm must avoid getting into a never-ending loop.
Algorithms f3

Notation
Concerning notation, we have one fundamental principle:
• The algorithm must be expressed in a language or notation that the processor 'under
stands'.
This principle should be self-evident. We cannot expect a weaving machine, or even a
computer, to perform an algorithm expressed in natural language. A machine must be
programmed in its own language.
On the other hand, an algorithm intended for humans need not necessarily be expressed
in natural language. Special-purpose notations are commonly used for certain classes of
algorithm. A musical score is an algorithm to be performed by a group of musicians, and
is expressed in the standard musical notation. A knitting pattern is an algorithm for either
a human or a knitting machine, and is generally expressed in a concise notation invented
for the purpose.
Here we restrict our attention to computational algorithms. Even so, we have a variety
of possible notations including natural language, programming language, mathematical
notation, and combinations of these. In this book we shall express all algorithms in
English, occasionally (and where appropriate) augmented by mathematical notation.
The choice of a natural language gives us the greatest possible freedom of expression;
both programming languages and mathematical notation are sometimes restrictive or
inconvenient.
We should remember, however, that expressing an algorithm in a natural language
always carries a risk of vagueness or even ambiguity. We must take great care to express
the individual steps of the algorithm, and the order in which these steps are to be
performed, as precisely as possible.
We have already seen several examples of algorithms, in Section 1.1, which you
should now re-examine. Note the use of layout and numbering to show the structure of
an algorithm. We number the steps consecutively, and arrange one below another in the
intended order, e.g.:

1. Do this.
2. Do that.
3. Do the other.

We use indentation and the numbering system to show when one or more steps are to
be performed only if some condition is satisfied:

1. If the condition is satisfied:


1.1. Do this.
1.2. Do that.
2. Carry on.

Likewise, we use indentation and the numbering system to show when one or more
steps are to be performed repeatedly while (or until) some condition is satisfied:
14 Java Collections

1. While (or until) the condition is satisfied, repeat:


1.1. Do this.
1.2. Do that.
2. Carry on.

or when one or more steps are to be performed repeatedly as a variable v steps through a
sequence of values:

1. For v = sequence of values, repeat:


1.1. Do this.
1.2. Do that.
2. Carry on.

2.2 Efficiency of algorithms


Given an algorithm, we are naturally interested in discovering how efficient it is. Effi-
ciency has two distinct facets:
• Time efficiency is concerned with how much (processor) time the algorithm requires.
• Space efficiency is concerned with how much space (memory) the algorithm requires
for storing data.
Often we have a choice of different algorithms that solve the same problem. How
should we decide which of these algorithms to adopt? Naturally we tend to prefer the
most efficient algorithm.
Sometimes one algorithm is faster, while an alternative algorithm needs less space.
This is a classic space-time tradeoff, which can only be resolved with knowledge of the
context in which the chosen algorithm will be used.
In this book we shall tend to pay more attention to time efficiency than to space
efficiency. This is simply because time efficiency tends to be the critical factor in choos-
ing between alternative algorithms.
Usually, the time taken by an algorithm depends on its input data. Figure 2.1 shows a
hypothetical profile of two alternative sorting algorithms, showing how the time they take
depends on n, the number of values to be sorted. Algorithm A is slightly faster for small n,
but algorithm B wins more and more easily as n increases.
How should we measure an algorithm's time efficiency? Perhaps the most obvious
answer is to use real time, measured in seconds. Real time is certainly important in many
practical situations. An interactive program that takes two minutes to respond to a user
input will quickly fall into disuse. An aircraft control system that takes 30 seconds to
respond to an abnormal altimeter reading will be eliminated by natural selection, along
with the unfortunate crew and passengers.
Nevertheless, there are difficulties in using real time as a basis for comparing algo-
rithms. An algorithm's real time requirement depends on the processor speed as well on
the algorithm itself. Any algorithm can be made to run faster by using a faster processor.
I5

Figure 2.1 Hypothetical profile of two sorting algorithms.

but this tells us nothing about the quality of the algorithm itself. And where the processor
is a modern computer, the difficulty is compounded by the presence of software and
hardware refinements - such as multiprogramming, pipelines, and caches - that increase
the average speed of processing, but make it harder to predict the time taken by an
individual algorithm.
We prefer to measure an algorithm's time efficiency in terms of the algorithm itself.
One idea is simply to count the number of steps taken by the algorithm until it terminates.
The trouble with this idea is that it depends on the granularity of the algorithm steps.
Algorithms 2.2(a) and (b) solve the same problem in 3 and 7 steps, respectively. But they
are just different versions of the same algorithm, one having course-grained (big) steps,
while the other has fine-grained (small) steps.

(a) (b)
To find the area of a triangle with sides a, b, c: To find the area of a triangle with sides a, b, c:
1. Let s = (a + b + c)/2. 1. Let s = (a + b + c)/2.
2. Let A = V(s (s – a ) ( s – b) (s – c)). 2. Let p = s.
3. Terminate with answer A. 3. Multiply p by (s – a).
4. Multiply p by (s – b).
5. Multiply p by (s – c).
6. Let A be the square root of p.
1. Terminate with answer A.

Algorithm 2.2 Algorithms to find the area of a triangle.


16 Java Collections

The most satisfactory way to measure an algorithm's time efficiency is to count


characteristic operations. Which operations are characteristic depends on the problem
to be solved. For an arithmetic algorithm it is natural to count arithmetic operations. For
example, Algorithm 2.2(a) takes two additions, three subtractions, three multiplications,
one division, and one square root; Algorithm 2.2(b) takes exactly the same number of
arithmetic operations. In this book we shall see many examples of algorithms where
comparisons or copies or other characteristic operations are the natural choice.

EXAMPLE 2.2 Power algorithms

Given a nonnegative integer n, the nth power of a number b. written bn. is defined by:
b" = b X - - - X b (2.1)
(where n copies of b are multiplied together). For example:
b23 = b x b x b
b 1== b X b
b b

Algorithm 2.3 (the 'simple' power algorithm) is based directly on definition (2.1). The
variable p successively takes the values 1, b, b2, b3, and so on - in other words, the
successive powers of b. Program 2.4 is a Java implementation of Algorithm 2.3.
Let us now analyze Algorithm 2.3. The characteristic operations are obviously multi-
plications. The algorithm performs one multiplication for each iteration of the loop, and
there will be n iterations, therefore:
No. of multiplications = n (2.2)
2 3
Algorithm 2.3 is fine if we want to compute small powers like b and b . but it is very
time-consuming if we want to compute larger powers like b20 and b100.
Fortunately, there is a better algorithm. It is easy to see that b20 = b10 x b10. So once
we know b10, we can compute b20 with only one more multiplication, rather than ten
more multiplications. This shortcut is even more effective for still larger powers: once we
know b50, we can compute b100 with only one more multiplication, rather than fifty.
Likewise, it is easy to see that b21 = b10 X b10 X b. So once we know b10. we can
compute b21 with only two more multiplications, rather than eleven.
Algorithm 2.5 (the 'smart' power algorithm) takes advantage of these observations.
The variable q successively takes the values b, b2, b4, b8, and so on. At the same time, the
variable m successively takes the values n, n/2, n/4, and so on (neglecting any remain-
ders) down to 1. Whenever m has an odd value, p is multiplied by the current value of q.
Program 2.6 is a Java implementation of Algorithm 2.5.
This algorithm is not easy to understand, but that is not the issue here. Instead, let us
focus on analyzing its efficiency.
First of all, note that steps 2.1 and 2.2 each performs a multiplication, but the multi-
plication in step 2.1 is conditional. Between them, these steps perform at most two
multiplications.
17

Next, note that these steps are contained within a loop, which is iterated as often as we
can halve the value of n (neglecting any remainder) until we reach zero. It can be shown
(see Appendix A.2) that the number of iterations is floor(log2n) + 1, where floor(r) is the
function that converts a real number r to an integer by discarding its fractional part,
Putting these points together:
Maximum no. of multiplications = 2 (floor(log2n) + 1)
= 2 floor(log 2 n) + 2 (2.3)
The exact number of multiplications depends on the value of n in a rather complicated
way. For n = 15 the actual number of multiplications corresponds to (2.3), since halving
15 repeatedly gives a series of odd numbers; while for n = 16 the actual number of
multiplications is smaller, since halving 16 repeatedly gives a series of even numbers.
Equation (2.3) gives us the maximum number of multiplications for any given n, which is
a pessimistic estimate.
Figure 2.7 plots (2.2) and (2.3) for comparison. The message should be clear. For
small values of n, there is little to choose between the two algorithms. For larger values of
/?., the smart power algorithm is clearly better; indeed, its advantage grows as n grows.

2.3 Complexity of algorithms


If we want to understand the efficiency of an algorithm, we first choose characteristic
operations, and then analyze the algorithm to determine the number of characteristic

To compute bn (where n is a nonnegative integer):


1. Setpto 1.
2. For i = 1, ..., n, repeat:
2.1. Multiply p by b.
3. Terminate with answer p.

Algorithm 2.3 Simple power algorithm.

static int power (int b, int n) {


/ / Return the value of b raised to the n'th power (where n is a nonnegative
/ / integer).
int p = 1 ;
for (int i = 1; i <= n; i++)
p *= b;
return p;

Program 2.4 Java implementation of the simple power algorithm.


18 lava Collections

To compute bn (where n is a nonnegative integer):


1. Set p to 1, set q to b, and set m to n.
2. While m is positive, repeat:
2.1. If m is odd, multiply p by q.
2.2. Halve m (neglecting any remainder), and multiply q by itself.
3. Terminate with answer p.

Algorithm 2.5 Smart power algorithm.

static int power (int b, int n) {


/ / Return the value of b raised to the n'th power (where n is a nonnegative
/ / integer).
int p = 1, q = b, m = n;
while (m > 0) {
if (m%2 != 0) p *= q;
m /= 2; q *= q;
}
return p;
}

Program 2.6 Java implementation of the smart power algorithm.

operations performed by it. In general, the number of characteristic operations depends


on the algorithm's input data.
For some algorithms (like the simple power algorithm in Example 2.2) the analysis is
straightforward. For other algorithms (like the smart power algorithm in Example 2.2) the
analysis is more complicated. We sometimes have to make simplifying assumptions, and
we sometimes have to be content with estimating the maximum (or average) number of
characteristic operations rather than the exact number.
The simple power algorithm takes n multiplications, while the smart power algorithm
takes at most 2 floor(log2n) + 2 multiplications. If we double n, the simple power algo-
rithm takes twice as many multiplications, while the smart power algorithm takes at most
two extra multiplications. Now this is the heart of the matter. When we compare the
efficiencies of alternative algorithms, what is most illuminating is the comparison of
growth rates. The function 2 floor(log2n) + 2 grows much more slowly than n. The
fundamental reason for this is that Iog2 n grows much more slowly than n. as shown in
Figure 2.8.
Of course we are interested in the actual times taken by alternative algorithms, but we
are especially interested in the rates at which their time requirements grow with n. This
interest in growth rates is easily justified. When n is small, we do not really care which
algorithm is fastest, because none of the algorithms will take much time. But when n is
large, we certainly do care, because all of the algorithms will take more time, and some
19

multipli-
cations
50–
simple powery
algorithm

40

30

20–

10-

0
10 20 30 40 50 n

Figure 2.7 Time efficiency of the simple and smart power algorithms.

might take much more time than others. All else being equal, we prefer the algorithm
whose time requirement grows most slowly with n.
If we have a formula for an algorithm's time requirement, we can focus on its growth
rate as follows:
• Take the fastest-growing term in the formula, and discard all slower-growing terms.
• Discard any constant factor in the fastest-growing term.
The resulting formula is called the algorithm's time complexity. We define space
complexity similarly.
20 lava Collections

40–

30-

20–

10-

10 20 30 40 n

Figure 2.8 Comparison of growth rates of n and log n.

EXAMPLE 2.3 Time complexity of power algorithms

The simple power algorithm's efficiency is given by equation (2.2):


No. of multiplications = n
The number of multiplications grows proportionately to n. We say that the simple power
algorithm's time complexity is of order n, and write this as:
0(n)
(The analysis in this particular example was trivial, but if the number of multiplications
had been 2n + 3, the time complexity would still have been O(n).)
The smart power algorithm's efficiency is given by equation (2.3):
Maximum no. of multiplications = 2 floor(log2n) + 2
Discarding the slower-growing term ( + 2 ) and the constant factor (2), we get
floor(log2n). We can approximate this as Iog2n. Thus the number of multiplications
grows proportionately to Iog2n. We say that the smart power algorithm's time
complexity is of order log n, and write this as:
O(log n)
21

Figure 2.8 shows that an O(log n) algorithm is inherently better than an O(n) algorithm.
Regardless of constant factors and slower-growing terms, the O(log n) algorithm will
eventually overtake the O(n) algorithm as n grows.
We have now introduced the O-notation for algorithm complexity. The notation O(X)
stands for 'of order X', and means that the algorithm's time (or space) requirement grows
proportionately to X. X characterizes the algorithm's growth rate, neglecting slower-
growing terms and constant factors. In general, X depends on the algorithm's input data.
Table 2.9 summarizes the most common time complexities. These are common
enough to have acquired verbal descriptions: for example, we say that the simple
power algorithm is a linear-time algorithm, while the smart power algorithm is a log-
time algorithm. The complexities are arranged in order of growth rate: 0(1) is the slow-
est-growing, and 0(2") is the fastest-growing.
It is important to develop our intuitions about what these complexities tell us, in
practical terms, about the time efficiency of algorithms. Table 2.10 shows some numer-
ical information, and Figure 2.11 shows the same information graphically. As we have
already noted, log n grows more gradually than n, so an 0(log n) algorithm is better than
an O(n) algorithm that solves the same problem. Of course, the constant 1 does not grow
at all, so an 0(1) or constant-time algorithm is best of all - if we can find one!
Now study the growth rate of n log n. This grows more steeply than n, so an O(n)
algorithm is better than an O(n log n) algorithm that solves the same problem.
Now study the growth rates of n2 and n3 . These grow ever more steeply, so an
O(n log n) algorithm is better than an O(n2) algorithm, which in turn is better than
an 0(«3) algorithm, that solves the same problem. One way to look at these algorithms
is this: every time n is doubled, O(n 2 ) is multiplied by four and O(n3) is multiplied by
eight. And every time n is multiplied by 10, O ( n 2 ) is multiplied by 100 and O(n3) is
multiplied by 1000! These numbers are discouraging. If the best algorithm we can find
is O(n2) or O(n 3 ), we have to accept that the algorithm will rapidly slow down as n
increases. Such an algorithm is often too slow to be of practical use.
While n2 and n3 grow steeply, 2" grows at a stupendous rate. Every time n is incre-
mented by 10, 0(2") is multiplied by over 1000! As n is increased from 10 to 20 to 30 to
40, 2" grows from a thousand to a million to a billion to a trillion. If the algorithm
performs 2" operations at the rate of a million per second, its time requirement will
grow from a millisecond to a second to over 16 minutes to over 11 days! Such an

Table 2.9 Summary of common time complexities.

Complexity Verbal description Feasibility

Oil) constant time feasible


O(log n) log time feasible
O(H) linear time feasible
O(n log n) log linear time feasible
0(n 2 ) quadratic time sometimes feasible
O(n 3 ) cubic time less often feasible
O(2 n ) exponential time rarely feasible
22 lava Collections

Table 2.10 Comparison of growth rates.


n 10 20 30 40
1 1 1 1 1
log n 3.3 4.3 4.9 5.3
n 10 20 30 40
n log n 33 86 147 213
n2 100 400 900 1 600
n 1 000 8000 27 000 64000
2n 1 024 1.0 million 1.1 billion 1.1 trillion

120–
n log n

100-

80–

60-

40–

20–

10 20 30 40 n

Figure 2.11 Comparison of various growth rates.


23

algorithm is nearly always far too slow to be used in practice, and even a much faster
processor makes hardly any difference (see Example 2.4).
We say that an algorithm is feasible if it is fast enough to be used in practice. Likewise.
we say that a problem is feasible if it can be solved by a feasible algorithm.
Algorithms of complexity up to O(n log n) are feasible. Algorithms of complexity
O(n2) or O(n3) might be feasible, but only for small values of n. Algorithms of complex-
ity 0(2n) are infeasible, except possibly for very small values of n.

EXAMPLE 2.4 Growth rates


Suppose that we are given three algorithms that solve the same problem, with complex-
ities O(n), O(n2), and O(n2), respectively. Measurement shows that their actual running
times on a particular processor are O.ln seconds, 0.0ln2 seconds, and 0.0001 X 2"
seconds, respectively, where n is the number of data items to be processed.
The following table shows the largest values of n for which the problem can be solved
in a second, a minute, and an hour:

Algorithm Running time Maximum n Maximum n Maximum n


(seconds) in 1 second in 1 minute in 1 hour

A 0.ln 10 600 36 000


B 0.01n2 10 77 600
C 0.0001 X2" 9 15 21

In one second, all three algorithms can process the same amount of data (by coincidence).
But there the similarity ends. In one minute, Algorithm A can process by far the most
data, and Algorithm C the least. If an hour is allowed, Algorithm A is out of sight!
How much difference does it make if we use a processor that is ten times faster? This
reduces each algorithm's running time by a factor of ten. The effects are as follows:

Algorithm Running time Maximum n Maximum n Maximum n


(seconds) in 1 second in 1 minute in 1 hour

A 0.01n 100 6 000 360 000


B 0.001n2 31 244 1 897
C 0.00001 X 2n 13 19 25

Ironically, Algorithm A (already the fastest) benefits the most, and Algorithm C (already
the slowest) benefits the least, from using the faster processor! Algorithm A can now
process ten times as much data in any given time, Algorithm B about three times as much
data, and Algorithm C only three extra data items.
Even if we handicap Algorithm A by leaving it to run on the slower processor, in as
little as a minute it beats Algorithm B and outclasses Algorithm C.
The moral of Example 2.4 is this. Constant factors are important only when comparing
algorithms of the same time complexity, such as two O(n) algorithms, or two O(n2)
algorithms. But an O(n) algorithm will beat an 0(n2) algorithm, sooner or later, regard-
24

less of constant factors. More generally, O(1) beats O(log n) beats O(n) beats O(n log n)
beats O(n2) beats O(n 3 ) beats O(2 n ).

2.4 Recursive algorithms


A recursive algorithm is an algorithm that calls itself.
When a recursive algorithm calls itself, it performs the same steps over again. This
repetition of steps is somewhat similar to the effect we get when the steps are part of a
loop. Indeed, often the same algorithm can be expressed either iteratively (using a loop)
or recursively.
Analogously, a recursive method is a method that calls itself. Indeed, a recursive
algorithm is most naturally coded in Java as a recursive method.

EXAMPLE 2.5 Recursive simple power algorithm


Let us return to computing the n'th power of b, i.e., bn, where n is a nonnegative integer.
The definition of bn in equation (2.1) led naturally to an iterative algorithm (Algorithm
2.3).
Here now is an alternative definition of b":
bn = 1 if n = 0 (2.4a)
bn = b x bn–1 if n > 0 (2.4b)
Equation (2.4b) says that we can compute the n'th power of b by taking the (n–l)'th
power of b and multiplying that by b. On its own, equation (2.4b) would be useless, but
equation (2.4a) tells us how to compute the 0'th power of b directly. For example:
b3 = b X b2 = b X (b X b1) = b X (b X (b X b0)) = b x ( b x ( b x 1 ) )
Equations (2.4a-b) together tell us all that we need to know.
These equations lead naturally to Algorithm 2.12. Step 1 deals with the easy case.
n = 0, when step 1.1 directly gives the answer 1. Step 2 deals with the hard case, n > 0.
when step 2.1 computes the answer with the help of a recursive call to the same algo-
rithm. Algorithm 2.12 is therefore recursive. (In this section, we shall highlight recursive
algorithm calls by underlining.)
Will Algorithm 2.12 terminate, or will it go on calling itself forever? We can reason as
follows. When called to compute the n'th power of b, with n > 0, the algorithm will call
itself to compute the (n–l)'th power of b, which is a smaller power of b. In fact it will call
itself repeatedly to compute successively smaller powers of b. Eventually it must call
itself to compute the 0'th power of b, and at this point it will give a direct answer without
calling itself again. Thus Algorithm 2.12 will indeed terminate.
Program 2.13 shows the recursive simple power algorithm coded as a recursive Java
method.
Let us now analyze the algorithm's time efficiency. The characteristic operations are
multiplications. Let mults(n) be the number of multiplications required to compute bn.
25

Then we can immediately write down the following equations:


mults(n) = 0 if n = 0 (2.5a)
mults(n) = 1 + mults(n – 1) if n > 1 (2.5b)
This is a pair of recurrence equations. We shall skip the mathematics and simply state the
solution:
mults(n) = n (2.6)
The recursive simple power algorithm performs exactly the same number of multiplica-
tions as the non-recursive simple power algorithm.

Example 2.5 suggests guidelines for ensuring that a recursive algorithm terminates:
• The problem must have one or more 'easy' cases and one or more 'hard' cases.
• In an 'easy' case, the algorithm must give a direct answer without calling itself.
• In a 'hard' case, the algorithm may call itself, but only to deal with an 'easier" case of
the same problem.
In Example 2.5, the problem had one easy case, n = 0, and one hard case, n > 0. In the
hard case, the algorithm called itself to deal with an easier case, n–1, and used that to
compute its answer.

To compute bn (where n is a nonnegative integer):


1. If n = 0:
1.1. Terminate with answer 1.
2. If n > 0:
2.1. Terminate with answer b x bn–1.

Algorithm 2.12 Recursive simple power algorithm.

static int power (int b, int n) {


/ / Return the value of b raised to the n'th power
/ / (where n is a nonnegative integer).
if (n == 0)
return 1;
else
return b * power(b, n - 1 ) ;
}
Program 2.13 Java implementation of the recursive simple power algorithm.
26 Java Collections

EXAMPLE 2.6 Recursive smart power algorithm


The smart power algorithm of Algorithm 2.5 is hard to understand. However, there is an
alternative version that is much more lucid. We observed in Example 2.2 that b20 =
b10 X b10 and b21 = b10 X b10 X b. Generalizing from this example:
bn = 1 if n = 0 (2.7a)
bn = bn/2 X bn/2 if n > 0 and n is even (2.7b)
bn = bn/2 X bn/2 xb if n > 0 and n is odd (2.7c)
(Remember that n/2 neglects the remainder if n is odd.)
Equations (2.4a–c) naturally lead to Algorithm 2.14, which is recursive. Step 1 is the
easy case, n = 0, and gives the answer directly. Step 2 is the hard case, n > 0, and works
by a recursive call to compute bn/2 (highlighted). Computing bn/2 is easier than computing
bn, since n/2 is smaller than n.
Program 2.15 shows the recursive smart power algorithm coded in Java.

To compute bn (where n is a nonnegative integer):


1. If n = 0:
1.1. Terminate with answer 1.
2. If n > 0:
2.1. Let p = bn/2. 2.
2.2. If n is even:
2.2.1. Terminate with answer p x p.
2.3. If n is odd:
2.3.1. Terminate with answer p x p x b.

Algorithm 2.14 Recursive smart power algorithm.

static int power (int b, int n) {


/ / Return the value of b raised to the n'th power (where n is a nonnegative
/ / integer).
if (n == 0)
return 1;
else {
int p = power(b, n / 2 ) ;
if (n%2 = =0) // n is even
return p * p;
else // n is odd
return p * p * b;

Program 2.15 Java implementation of the recursive smart power algorithm.


27

Many algorithms can be expressed using either iteration or recursion. (Compare Algo-
rithms 2.3 and 2.11, and compare Algorithms 2.5 and 2.14.) Typically the recursive
algorithm is more elegant and easier to understand, but less efficient, than the correspond-
ing iterative algorithm.
We do not always have a straight choice between iteration and recursion. For some
problems an iterative solution would be extremely awkward, and a recursive solution is
much more elegant.

EXAMPLE 2.7 Integer rendering

Rendering means converting data into a form suitable for printing or display on a screen.
Most often, data are rendered as character strings (although some data are suitable for
rendering graphically).
The problem is to render a given integer i to a given base (or radix) r between 2 and 10.
The rendered integer is to be signed only if negative. For example:

Rendering

+ 29 2 "11101"
+ 29 8 "35"
–29 8 "–35"
+ 29 10 "29"

We can view this problem in terms of three cases:


• If i < 0, we have a negative integer. So we should render a minus-sign '–' and then
render (–i) to the base r.
• If 0 < i < r, we have a single-digit nonnegative integer. So we should simply
render the required digit. (Note that we must carefully distinguish between the integers
0, 1, ..., 9 and the corresponding digits '0', '1',...,'9'. A digit is a character, and as
such can be printed or displayed on a screen. It is true that each digit has an
(integer) internal code, but the internal code of '9' (for example) is not 9.)
• If i > r, we have a multiple-digit nonnegative integer. If we divide i by r, the remain-
der can be rendered as the rightmost digit, and the quotient can be rendered as the
remaining digits. So we should render (i/r) to the base r and then render the single digit
corresponding to (i modulo r).
This naturally leads to Algorithm 2.16. Step 2 is the easy case (a small nonnegative
integer), which is solved directly. Step 3 is a harder case (a large nonnegative integer),
which is solved in part by calling the algorithm recursively to deal with an easier case (a
smaller nonnegative integer). Step 1 is also a harder case (a negative integer), which is
solved in part by calling the algorithm recursively to deal with an easier case (a nonne-
gative integer).
Program 2.17 shows the algorithm implemented as a recursive Java method.
28 Java Collections

EXAMPLE 2.8 Towers of Hanoi

Three vertical poles are mounted on a platform. A number of disks are provided, all of
different sizes, and each with a central hole allowing it to be threaded on to any of the
poles. Initially, all of the disks are on pole 1, forming a tower with the largest disk at the
bottom and the smallest disk at the top. Only a single disk may be moved at a time, from
the top of any tower to the top of another tower, but no larger disk may be moved on top
of a smaller disk. The problem is to move the tower of disks from pole 1 to pole 2.
According to legend, this task was originally set for the monks at the monastery of
Hanoi. Sixty-four disks were provided. Once the monks completed their task, the
universe would come to an end. How long should this take?
Rather than the particular problem of moving the tower of 64 disks from pole 1 to pole
2, it will prove helpful to address the more general problem of moving a tower of n disks
from pole source to pole dest.

To render an integer i to the base r (where r is an integer between 2 and 10):


1. If i < 0:
1.1. Render'–'.
1.2. Render (–i) to the base r.
2. If 0 < i < r.
2.1. Let d be the digit corresponding to ;'.
2.2. Render d.
3. If i > r.
3.1. Let d be the digit corresponding to (i modulo r).
3.2. Render (ilr) to the base r.
3.3. Render d.

Algorithm 2.16 Recursive integer rendering algorithm.

static String renderBasedInt (int i, int r) {


/ / Render i to the base r (where r is an integer between 2 and 10).
String s ;
if (i < 0) {
s = '-' + renderBasedlnt (-i, r) ;
} else if (i < r) {
char d = (char)('0' + i);
s = " " + d;
} else {
char d = (char)('0' + i%r) ;
s = renderBasedInt (i/r, r) + d;
}
return s ;

Program 2.17 Java implementation of the recursive integer rendering algorithm.


Exploring the Variety of Random
Documents with Different Content
tout appareillié de retourner sus yaus, et ensi les
arons nous mieulz à nostre aise.» Cilz consaulz fu
15 arestés de tous, et le tinrent pour le milleur entre yaus.
Adonc se retraist cescuns sires entre ses gens et dessous
se banière ou son pennon, ensi comme il devoit
estre, et puis sonnèrent leurs trompètes et fisent
grant samblant d’yaulz retraire; et commandèrent
20 tout chevalier et escuier et gens d’armes, leurs varlès
et garçons à passer le pont et mettre oultre le rivière
leur harnas. Si en passèrent pluiseur en cel estat et
priès ensi que tout, et depuis aucunes gens d’armes
faintement.
25 Quant messires Jehans Jeuiel, qui estoit appers
chevaliers et vighereus durement et qui avoit grant
desir des François combatre, perçut le manière comment
il se retraioient, si dist au captal: «Sire, sire,
descendons apertement; ne veés vous le manière
30 comment li François s’enfuient?» Dont respondi li
captaus et dist: «Messire Jehan, messire Jehan, ne
creés ja que si vaillant homme qu’il sont là, s’enfuient
[123] ensi; il ne le font fors par malisse et pour nous
attraire.» Adonc s’avança messires Jehans Jeuiaus,
qui moult engrans estoit de combatre, et dist à ceulz
de sa route, et en escriant: «Saint Jorge! Passés
5 avant! Qui m’aime, se me siewe: je m’en vois combatre.»
Dont se hasta il, son glave en son poing, par
devant toutes les batailles, et estoit ja avalés jus
de le montagne et une partie de ses gens, ançois
que li captaus se meuist. Quant messires li captaus
10 veit que c’estoit acertes et que Jehans Jeuiel
s’en aloit combatre sans lui, se le tint à grant
presumption, et dist à chiaus qui dalés lui estoient:
«Alons, alons, descendons la montagne apertement;
messires Jehans Jeuiaus ne se combatera point sans
15 mi.» Dont s’avancièrent toutes les gens dou captal,
et ils premierement, son glave en son poing.
Quant li François qui estoient en agait, les veirent
descendus et venus ou plain, si furent tout resjoy et
disent entre yaus: «Veci che que nous demandions
20 hui tout le jour.» Adonc retournèrent il tout à un fais,
en grant volenté de recueillier leurs ennemis, et
escriièrent d’une vois: «Nostre Dame! Claiekin!» Si
drecièrent leurs banières devers les Navarois, et
commencièrent les batailles à assambler de toutes pars,
25 et tout à piet. Evous monsigneur Jehan Jeuiel tout
devant, le glave ou poing, qui corageusement vint
assambler à le bataille des Bretons, desquels messires
Bertrans estoit chiés, et là fist tamainte grant apertise
d’armes, car il fu hardis chevaliers malement. Dont
30 s’espardirent ces batailles, cil chevalier et cil escuier
sus ces plains, et commencièrent à lancier, à ferir et à
fraper de toutes armeures, ensi que il les avoient à
[124] main, et à entrer en l’un l’autre par vasselage, et yaus
combatre de grant volenté. Là crioient li Englès et li
Navarois d’un lés: «Saint Jorge! Navare!» et li
François: «Nostre Dame! Claiekin!» Là furent moult
5 bon chevalier, dou costet des François: premierement
messires Bertrans de Claiekin, li jones contes d’Auçoirre,
li viscontes de Byaumont, messires Bauduins
d’Anekins, messires Loeis de Chalon, li jones sires de
Biaugeu messires Anthones, qui là leva banière, messires
10 Loeis de Haveskierke, messires Oudars de Renti,
messires Engherans d’Uedins; et d’autre part, li Gascon,
qui avoient leur bataille et qui se combatoient à
par yaus: premierement messires Aymenions de Pumiers,
messires Perducas de Labreth, messires li soudis
15 de Lestrade, messires Petiton de Courton et pluiseur
aultre, tout d’une sorte. Et s’adrecièrent cil
Gascon à le bataille dou captal et des Gascons: ossi
il avoient grant volenté d’yaus trouver. Là eut grant
hustin et dur puigneis, et fait tamainte grant apertise
20 d’armes.
Et pour ce que en armes on ne doit point mentir
à son loyal pooir, on me poroit demander que li
Arceprestres, qui là estoit uns grans chapitains et
qui tenoit grant route, estoit devenus, pour ce que
25 je n’en fai nulle mention. Je vous en dirai le verité.
Si tretost que li Arceprestres vei l’assamblement
de le bataille et que on se combateroit, il se
bouta hors des routes; mais il dist à ses gens et à
celui qui portoit se banière: «Je vous ordonne et
30 commande, sur quanques vous poés fourfaire envers
moy, que vous demorés et attendés fin de journée.
Je me pars sans retourner, car je ne me puis hui
[125] combatre ne estre armés contre aucuns chevaliers
qui sont par delà; et, se on vous demande de mi, si
en respondés ensi à chiaus qui en parleront.» Adonc
se parti il, et uns siens escuiers tant seulement, et rapassa
5 le rivière et laissa les aultres couvenir. Onques
François ne Breton ne s’en donnèrent garde, pour
tant que il veoient ses gens et se banière jusques en
le fin de le besongne, et le cuidoient dalés yaus. Or
vous parlerons de le bataille, comment elle fu perseverée,
10 et des grans apertises d’armes qui y furent faites
celle journée, ensi que vous orés.

§ 520. Au commencement de le bataille, quant


messires Jehans Jeuiel fu descendus, et toutes gens le
sievirent dou plus priès qu’il peurent, et meismement
15 li captaus et se route, et cuidièrent avoir le journée
pour yaus; mès il en fu tout aultrement. Quant li
Navarois veirent que li François estoient retournet
par bonne ordenance, il conçurent tantost qu’il s’estoient
fourfet. Nonpourquant, comme gens de grant
20 emprise, il ne s’esbahirent de riens, mès eurent bien
intention de tout recouvrer par bien combatre. Si
reculèrent un petit et se remisent ensamble, et puis
se ouvrirent et fisent voie à leurs arciers qui estoient
derrière yaus, pour traire. Quant li arcier furent devant,
25 si s’eslargirent et commencièrent à traire de
grant manière; mès li François estoient si fort armé
et si bien paveschié contre le tret, que onques il n’en
furent grevé, se petit non, ne pour ce n’en laissièrent
il point à combatre, mès entrèrent, et tout à piet, ens ès
30 Navarois et Englès, et cil entre eulz de grant volenté.
Là eut grant bouteis et lanceis des uns as aultres, et
[126] tolloient à l’un l’autre, par force de bras et de luitier,
leurs lances et leurs haces et les armeures dont
il se combatoient; et se prendoient et fiançoient prisonniers
li un l’autre, et se approçoient de si priès
5 que il se combatoient main à main si vaillamment
que nulles gens mieulz. Si poés bien croire que en
tel presse et en tel peril il en y avoit des mors et des
reversés grant fuison; car nulz ne s’espargnoit, d’un
costet ne d’aultre. Et vous di que li François n’avoient
10 que faire de dormir ne de reposer sus leur
bride, car il avoient gens de grant fait et de hardie
emprise à le main: si couvenoit çascun acquitter
loyaument à son pooir et deffendre son corps, et
garder son pas et prendre son avantage, quant il venoit
15 à point; aultrement il euissent esté tout desconfi.
Si vous di pour verité que li Breton et li
Gascon y furent là très bonnes gens, et y fisent pluiseurs
belles apertises d’armes.
Or vous voeil je compter des trente qui estoient
20 esleu pour yaus adrecier au captal, et [estoient[423]] trop
bien monté sus fleurs de coursiers. Chil qui n’entendoient
à aultre cose que à leur emprise, si com cargié
en estoient, s’en vinrent tout serré là où li captaus se
combatoit moult vaillamment d’une hace et donnoit
25 les cops si grans que nulz ne l’osoit approcier, et
rompirent le priesse par force de chevaus, et ossi
[parmi[424]] l’ayde des Gascons qui leur fisent voie. Cil
trente qui estoient trop bien monté, ensi que vous
savés, et qui savoient quel cose il devoient faire, ne
[127] veurent mies ressongnier le painne ne le peril; mès
vinrent jusques au captal et l’environnèrent, et s’arrestèrent
dou tout sur lui, et le prisent et embracièrent
de fait entre yaus par force, et puis vuidièrent
5 le place et l’emportèrent en cel estat. Et en ce lieu
eut adonc grant abateis et dur puigneis, et se commencièrent
toutes les batailles à converser de celle
part, car les gens dou captal, qui sambloient bien
foursené, crioient: «Rescousse au captal! Rescousse!»
10 Nientmains, ce ne leur peut valoir ne aidier: li captaus
en fu portés et ravis en le manière que je
vous di, et mis à sauveté; de quoi, en l’eure que ce
avint, on ne savoit encores de verité liquel en aroient
le milleur.
15 § 521. En ce toueil et en ce grant hustin et froisseis,
et que Navarois et Englès entendoient à sievir le
trace dou captal qu’il en veoient mener [et porter[425]]
devant yaus, dont il sambloient tout foursené, messires
Aymenions de Pumiers, messires Petiton de
20 Courton, messires li soudis de Lestrade et les gens le
signeur de Labreth, d’une sorte, entendirent de grant
volenté à yaus adrecier au pennon le captal qui estoit
en un buisson et dont li Navarois faisoient leur estandart.
Là eut grant hustin et dur et forte bataille,
25 car il estoit bien gardés et de bonnes gens, et par
especial messires li bascles de Marueil et messires
Joffrois de Rousseillon y estoient. Là eut fait tamainte
grant apertise d’armes, mainte prise et mainte rescousse,
et maint homme blecié et navré et reversé
[128] par terre, qui onques depuis ne se relevèrent. Toutesfois,
li Navarois, qui là estoient dalés ce buisson et
le pennon dou captal, furent ouvert et reculé par
force d’armes, et mors li bascles de Marueil et pluiseur
5 aultre, et pris messires Joffrois de Rousseillon et
fianchiés prisons de monsigneur Aymenion de Pumiers,
et tout li aultre qui là estoient, mort ou pris
ou reculé si avant qu’il n’en estoit là nulle nouvelle
entours le buisson, quant li pennons dou dit captal
10 fu pris et conquis et deschirés et rués par terre.
Entrues que li Gascon entendoient à ce faire, li Pikart,
li François, li Normant, li Breton et li Bourghegnon
se combatoient d’autre part moult vaillamment. Et
bien leur besongnoit, car li Navarois les avoient reculés,
15 et [estoit demourez[426]] mort entre yaus, dou costé
des François, li viscontes de Byaumont, dont ce fu
damages; car il estoit à ce jour jones chevaliers et
bien tailliés de valloir encores grant cose. Si l’avoient
ses gens à grant meschief porté hors de le priesse
20 ensus de le bataille, et là le gardoient. Je vous di,
si com je oy depuis recorder ceulz qui y furent d’un
costé et d’autre, que on n’avoit point veu la pareille
bataille de celle, de otèle quantité de gens, estre ossi
bien combatue comme celle fu; car il estoient tout à
25 piet et main à main. Si s’entrelaçoient li un dedens
l’autre, et s’esprouvoient au bien combatre de telz
armeures qu’il portoient; et par especial de ces haces
donnoient il si grans horions que tout s’estonnoient.
Là furent navré et durement blecié messires Petitons
30 de Courton et messires li soudis de Lestrade, et telement
[129] que depuis, pour le journée, ne se peurent aidier.
Messires Jehans Jeuiel, par qui la bataille commença
et qui de premiers moult vassaument avoit
assaillis et envaïs les François, y fist ce jour tamainte
5 grant apertise d’armes, et ne daigna onques reculer, et
se embati si avant qu’il fu durement bleciés et navrés
en pluiseurs lieus ou corps et ou cief, et fu pris et
fianciés prisons d’un escuier de Bretagne desous le
banière monsigneur Bertran de Claiekin: adonc fu il
10 portés hors de la presse. Li sires de Biaugeu, messires
Loeis de Chalon, les gens de l’Arceprestre, avoech
grant fuison de bons chevaliers et escuiers de Bourgongne,
se combatoient d’autre part moult vaillamment
et bien savoient à qui respondre; car une route
15 de Navarois et les gens à monsigneur Jehan Jeuiel
leur estoient au devant. Et vous di que li François
ne l’avoient point d’avantage, car il trouvoient dures
gens merveilleusement contre yaus. Messires Bertrans
et si Breton se acquittèrent loyaument bien et
20 se tinrent tousjours ensamble, en aidant l’un l’autre.
Et ce qui desconfi les Navarois et Englès, ce
fu la prise du captal, qui fu pris très le commencement,
et le conquès de son pennon, où ses gens
ne se peurent ralloiier. Li François obtinrent le
25 place, mès il leur cousta grandement des leurs; et y
furent mort, de leur costé, li viscontes de Byaumont,
si com vous avés oy, messires Bauduins d’Anekins,
mestres des arbalestriers, messires Loeis de Haveskierke
et pluiseur aultre. Et des Navarois, mors uns
30 banerès de Navare qui s’appelloit li sires de Saus, et
grant fuison de ses gens dalés lui, et mors messires
li bascles de Marueil, uns apers chevaliers durement,
[130] si com dessus est dit, et ossi morut ce jour prisonniers
messires Jehans Jeuiel. Si y furent pris messires
Guillaumes de Gauville, messire Pierres de Sakenville,
messires Joffrois de Roussellon, messires
5 Bertrans dou Franch et pluiseur aultre: petit s’en
sauvèrent que tout ne fuissent ou mort ou pris
sus le place. Ceste bataille fu en Normendie assés
priès de Coceriel, par un joedi, le [seizième[427]] jour
de may, l’an de grasce mil trois cens soissante
10 quatre.

§ 522. Apriès ceste desconfiture, et que tout li


mort estoient ja desvesti, et que cescuns entendoit à
ses prisonniers, qui les avoit, ou à lui mettre à point,
qui bleciés estoit, et que ja la grignour partie des
15 François avoient rapasset le pont et le rivière et se
retraioient à leurs logeis, tout foulé et tout lassé, furent
il en aventure d’avoir aucun meschief, dont il
ne se donnoient garde. Je vous dirai comment.
Messires Guis de Gauville, filz à monsigneur Guillaume
20 de Gauville, qui pris estoit sus le place, estoit
partis de Konces, une garnison navaroise; car
il avoit entendu que leurs gens se devoient combatre,
ensi qu’il fisent; et durement s’estoit hastés pour
estre à celle journée, ou à tout le mains il esperoit
25 que à l’endemain on se combateroit. Si voloit estre
dalés le captal, comment qu’il fust, et avoit en se
route environ cinquante lances de bons compagnons
et tous bien montés. Li dis messires Guis et se route
s’en vinrent tout, à brochant les grans eslais, jusques
[131] en le place où la bataille avoit esté. Li François, qui
estoient derrière et qui nulle garde ne s’en donnoient
de celle sourvenue, sentirent la friente; si se reboutèrent
tantost tous ensamble et s’en vinrent
5 contre les Navarois, en escriant: «Retournés! Retournés!
Veci les ennemis!» De cel effroi furent
li pluiseur moult effraé, et là fist messires Aymenions
de Pumiers à leurs gens un grant confort: encores
estoit il, et toute se route, sus le place. Sitos comme
10 il vei ces Navarois approcier, il se retrest sus dextre
et fist desvoleper son pennon, et lever et mettre tout
hault sus un buisson, par manière d’estandart, pour
ralloiier leurs gens.
Quant messires Guis de Gauville, qui en haste
15 estoit adreciés sus le place, en vei le manière et recognut
le pennon monsigneur Aymenion de Pumiers,
et oy escrier: «Nostre Dame! Claiekin!» et ne perçut
nullui de chiaus qu’il demandoit, mès en veoit
grant fuison tous mors gesir par terre, si cogneut
20 tantost que leurs gens avoient estet desconfi, et li
François obtenu le place. Si fist tant seulement un
puigneis, sans faire nul samblant de combatre, et
passa oultre assés priès de monsigneur Aymenion de
Pumiers qui estoit tous appareilliés de lui recueillier,
25 se il fust traist avant, et s’en rala son chemin ensi
comme il estoit venus: je croi bien que ce fu devers
le garnison de Conces.
Or parlerons nous des François comment il perseverèrent.
La journée, ensi que vous avés entendu,
30 fu pour yaus, et rapassèrent le soir oultre le rivière,
et se traisent à leurs logeis, et se aisièrent de ce qu’il
eurent. Si fu li Arceprestres durement demandés et
[132] deparlés, quant on se perçut qu’il n’avoit point estet
a le bataille et qu’il s’en estoit partis sans parler. Si
l’escusèrent ses gens au mieulz qu’il peurent. Et sachiés
que li trente, qui le captal ravirent et emportèrent,
5 ensi que vous avés oy, ne cessèrent onques de chevaucier,
si l’eurent amené ou chastiel de Vrenon et
là dedens mis à sauveté. Quant ce vint à l’endemain,
il se deslogièrent et toursèrent tout, et chevaucièrent
par devers Vrenon, pour venir en le cité de
10 Roem, et tant fisent qu’il y parvinrent. En le cité et
ou chastiel de Roem laissièrent il une partie de
leurs prisonniers, et s’en retournèrent li pluiseur à
Paris, tout liet et tout joiant, c’estoit raisons; car il
avoient eu une moult belle journée pour yaus, et
15 moult pourfitable pour le royaume de France. Car,
se li contraires fust avenus as François, messires li
captaus de Beus euist fait un grant escars en France;
car il avoit empris et en pourpos que de chevaucier
jusques à Rains, au devant dou duch de Normendie,
20 qui ja y estoit venus pour lui faire couronner et
consacrer, et la duçoise sa femme o lui; mès Diex ne
le veult mies consentir: ce doit on moult bien
esperer.

§ 523. Ces nouvelles s’espardirent en pluiseurs


25 lieus, que li captaus estoit pris et toutes ses gens rués
jus. Si en acquist messires Bertrans de Claiekin grant
grasce et grant renommée de toutes manières de
gens ou royaume de France, et en fu ses noms moult
eslevés. Si vinrent les nouvelles jusques au duch de
30 Normendie qui estoit à Rains; si s’en resjoy grandement
et en loa Dieu pluiseurs fois. Si en fu sa cours
[133] et toutes les cours des signeurs qui là estoient venu
à son couronnement, plus liet et plus joiant.
Ce fu le jour de le Trinité l’an de grasce Nostre
Signeur mil trois cens soissante quatre que li rois
5 Charles, ainsnés filz dou roy Jehan de France, fu
couronnés et consacrés à roy en le grant eglise Nostre
Dame de Rains, et ensi madame la royne sa femme,
fille au duch Pière de Bourbon, de reverent père en
Dieu monsigneur Jehan de Cran, arcevesque de
10 Rains. Là furent li rois Pières de Cippre, li dus
d’Ango, li dus de Bourgongne, messires Wincélaus
de Behagne, dus de Lussembourch et de Braibant,
oncles au dit roy, li contes d’Eu, li contes de Dammartin,
li contes de Tankarville, li contes de Wedimont,
15 messires Robers d’Alençon, li arcevesques de
Sens, li arcevesques de Roem et tant de prelas et de
signeurs que je ne les aroie jamais tous nommés: si
m’en passerai briefment. Si y furent adonc les festes
et les solennités grandes. Et demorèrent li rois de
20 France et la royne en le cité de Rains cinq jours. Si
y eut grans dons et grans presens donnés et presentés
as signeurs estragniers, dont la plus grant
partie prisent là congiet au dit roy et retournèrent
en leurs lieus.
25 Si retourna li rois de France devers Paris à petites
journées et à grans esbatemens, et grant fuison
de prelas et de signeurs avoecques lui, et toutdis li
fist li rois de Cippre compagnie. On ne vous poroit
mies dire ne recorder, en un jour d’esté, les solennités
30 ne les grans reviaus que on li fist en le cité de
Paris, quant il y entra. Si estoient ja revenu à Paris
la grigneur partie des signeurs et chevaliers qui
[134] avoient esté à le besongne de Koceriel. Si leur fist
li rois grant fieste et les vei moult volentiers, et par
especial monsigneur Bertran de Claiekin et les chevaliers
de Gascongne, monsigneur Aymenion de Pumiers
5 et les autres, car li sires de Labreth avoit esté
à son couronnement.
§ 524. A le revenue dou roy de France à Paris, fu
pourveus et ravestis dou duçainné de Bourgongne
messires Phelippes ses mainsnés frères. Et se parti de
10 Paris à grant gent et en ala prendre le saisine et possession
et l’ommage des barons, chevaliers, cités,
chastiaus et bonnes villes de la ditte ducé. Quant li
dus de Bourgongne eut viseté tout son pays, il retourna
en France en grant solas, et ramena avoecques
15 lui son compère monsigneur l’Arceprestre, et le rapaisa
au roy parmi bonnes escusances que li Arceprestres
moustra au dit roy de ce que adonc, à le journée
de Coceriel, il ne se pooit armer contre le captal. Et
meismement li captaus, qui estoit adonc amenés à
20 Paris dalés le roy et qui avoit juret à là tenir prison,
et à le priière le signeur de Labreth et des Gascons li
avoit li dis rois eslargi celle grasce, aida le dit Arceprestre
à escuser devers le roy et les chevaliers de
France qui parloient villainnement sus se partie. Et
25 ossi il avoit fait de nouviel aucuns biaus services au
roy de France et au duch de Bourgongne, car il
avoit en la ditte ducé de Bourgongne ruet jus, au
dehors de Digon, bien quatre cens pillars, des quelz
Guios dou Pin, Tallebart Tallebardon, Jehan de Caufour
30 et Thiebaut de Caufour estoient meneur et chapitainne:
pour quoi li rois descendi plus legierement
[135] à lui faire grasce et de pardonner son mautalent.
Si fist li dis rois en ce temps coper le chief à
monsigneur Pière de Sakenville, en le cité de Roem,
5 pour tant qu’il avoit esté navarois; et messires Guillaumes
de Gauville n’en euist eu mies mains, se
n’euist esté messires Guis ses filz, qui segnefia au roy
de France que, se on faisoit son père nulle griefté,
il le feroit samblablement à monsigneur Braimont de
10 Laval, un grant signeur de Bretagne, qu’il tenoit son
prisonnier ens ou chastiel d’Evrues. De quoi li linages
dou chevalier, qui sentoient leur cousin en ce
peril, en parlèrent au roy et fisent tant que par escange
il reurent monsigneur Braimont, et messires
15 Guillaumes de Gauville fu delivrés: ensi se portèrent
les pareçons. Si fu envoiiés li captaus, de Paris à
Miaus en Brie, et là tenoit prison, entrues que li dus
de Bourgongne fist une chevaucie en Biausse dont je
vous parlerai. Mais ançois racquitta messires Bertrans
20 de Claiekin le chastiel de Roleboise, dont Wautre
Obstrate estoit chapitains; mais ançois qu’il le volsist
rendre, il en eut une grande somme de florins, ne
sçai cinq ou six mil frans, et puis s’en retourna arrière
en Braibant dont il estoit.
25 Encores se tenoient pluiseurs forterèces en Kaus,
en Normendie, ou Pierce, en Biausse et ailleurs qui
trop fort herioient le royaume de France, li aucun
en l’ombre dou roy de Navare, et li aultre d’eulz
meismes, pour pillier et pour rober sus le royaume
30 à nul title de raison. Si en desplaisoit grandement
au roy de France, car les complaintes en venoient
tous les jours à lui: si y veult pourveir de remède.
[136] Et y envoia son frère le duc de Bourgongne, et grant
fuison de bons chevaliers et escuiers en se compagnie.
Et fist li dis dus son mandement et son amas
de gens d’armes en le cité de Chartres. Si se partirent
5 de là, quant tout furent assamblé, et se traisent par
devers Macheranville, un moult fort chastiel que li
Navarois tenoient. Et pour constraindre mieulz à
leur aise le dit chastiel, il en fisent mener et achariier
avoech eulz pluiseurs engiens de la cité de Chartres.
10 Si estoient en le compagnie dou duch de Bourgongne
messires Bertrans de Claiekin, messires Boucicaus,
mareschaus de France, li contes d’Auçoirre, messires
Loeis de Chalon, li sires de Biaugeu, messires Aymenions
de Pumiers, li sires de Rainneval, li Beghes de
15 Vellainnes, messires Nicoles de Ligne, mestre des
arbalestriers pour le temps, messires Oudars de
Renti, messires Engherans du Edins et pluiseur aultre
bon chevalier et escuier.
Si s’arroutèrent ces gens d’armes par devers Marcerainville,
20 et estoient bien cinq mil combatans.
Quant il se veirent si grant fuison sus les camps,
si eurent conseil que il se departiroient en trois
pars, pour plus tost constraindre leurs ennemis:
desquèles pars messires Bertrans de Claiekin en prenderoit
25 jusques à mil combatans et s’en iroit par deviers
Constentin et sus les marces de Chierebourch,
pour garder là les frontières que li Navarois ne
fesissent nul damage au pays de Normendie. Si se
departi li dis messires Bertrans de le route dou
30 duch et enmena avoecques lui monsigneur Loeis de
Sanssoirre, le conte de Joni, monsigneur Ernoul
d’Audrehen et grant fuison de chevaliers et d’escuiers
[137] de Bretagne et de Normendie. L’autre charge
eut desous lui messires Jehans de le Rivière et se
departi ossi de le route dou duch, et en se compagnie
grant fuison de chevaliers et d’escuiers de
5 France et de Pikardie. Et entrèrent cil en le conté
d’Evrues et s’en vinrent seoir devant un chastiel que
on dist d’Akegni. Et li dus de Bourgongne et la plus
grosse route s’en vinrent devant Macerenville; si le
assegièrent et environnèrent de tous poins. Et fisent
10 tantost drecier et ass[eo]ir les engiens par devant,
qui jettoient nuit et jour à le forterèce et durement le
constraindoient.

§ 525. Entrues que ces gens d’armes estoient ensi


en Biausse et en Normendie et que il guerrioient asprement
15 et fortement les Navarois et les ennemis
dou royaume, estoit [sur les marches d’Auviergne, à
tout bien trois mille combatans[428]], messires Loeis de
Navare, frères mainnés au roy de Navare et ossi à
monsigneur Phelippe qui fu, car ja estoit il trespassés
20 de ce siècle, liquels messires Loeis avoit encargiet
le fais de le guerre pour le roy son frère, et avoit
deffiiet le roy de France, pour tant que ceste guerre
touchoit au calenge de lor hiretage, si com enfourmés
estoit, et avoit rassamblés depuis le bataille de
25 Koceriel, et rassambloit encores tous les jours, gens
d’armes, là où il les pooit avoir. Si avoit tant fait
par moiiens et par chapitains de Compagnes, dont
encores avoit grant fuison ens ou royaume de
France, que il avoit bien douze cens combatans en
[138] se route. Et estoient dalés lui messires Robers Canolles,
messires Robers Ceni, messires Robers Brikés
et Carsuelle. Et estoient ces gens d’armes, qui
tous les jours croissoient, logiet entre le rivière de
5 Loire et le rivière d’Allier, et avoient courut une
grant partie dou pays de Bourbonnois environ Moulins
en Auvergne et Saint Pierre le Moustier et Saint
Poursain.
De ces gens d’armes que messires Loeis de Navare
10 menoit, se parti une route de compagnons, environs
quatre cens, desquels Bernars de la Salle et
Hortingo estoient conduiseur, et passèrent le Loire
au dehors de Marcelli les Nonnains, et puis chevaucièrent
tant par nuit, car les jours il se tenoient ens
15 ès bois sans yaus amoustrer, que sus un ajournement
il vinrent à la Charité sus Loire, une grosse
ville et bien fremée: si l’eschiellèrent sans nul estri
et se boutèrent dedens. Or aida adonc Diex trop
bien chiaus de le ville; car, se cil compagnon se
20 fuissent hasté, il euissent pris et eu hommes et femmes
et moult grant pillage en la Charité; mès riens n’en
fisent: je vous dirai pourquoi. A ce lés par où il
entrèrent en le ville de le Charité, a une grande
place entre le porte et le ville, où nuls ne demeure.
25 Si cuidièrent adonc li compagnon que les gens euissent
fait embusce en le ville et qu’il les attendesissent:
si n’osèrent aler avant jusques atant qu’il fu
grans jours. En ce terme se sauvèrent cil de la ville;
car, si tretos comme il sentirent leurs ennemis ensi
30 venus, il enportèrent à effort leurs milleurs coses ens
ès batiaus qui estoient sus le rivière de Loire, et misent
femmes et enfans tout à loisir, et puis nagièrent
[139] à sauveté devers la cité de Nevers, qui siet à cinq
liewes de là. Quant il fu grans jours, li Navarois et
Englès et Gascon qui avoient eschiellé le ville, se
traisent avant et trouvèrent les maisons toutes vuides.
5 Si eurent conseil que celle ville il tenroient et le
fortefieroient, car elle lor seroit trop bien seans pour
courir deçà et delà le Loire. Si envoiièrent tantost
noncier tout leur fait à monsigneur Loeis de Navare
qui se tenoit en le marce d’Auvergne, comment il
10 avoient esploitié et qu’il tenoient le Charité sus Loire.
De ces nouvelles fu li dis messires Loeis tous joians,
et y envoia incontinent monsigneur Robert Briket
et Carsuelle, à bien trois cens armeures de fier. Cil
passèrent parmi le pays sans contredit, et entrèrent
15 par le pont sus Loire en la Charité. Quant il se trouvèrent
ensamble, si furent plus fort, et commencièrent
à guerriier fortement et destroitement le dit
royaume, et couroient à leur aise et volenté par deçà
et delà le Loire, ne nulz ne leur aloit au devant, et
20 toutdis leur croissoient gens. Or vous parlerons dou
duch de Bourgongne et dou siège de Macerenville.

§ 526. Tant sist li dis dus devant Macerainville et


le constraindi et apressa, par assaus et par les engiens
qui jettoient nuit et jour, que cil qui dedens estoient
25 se rendirent, salve leurs corps et leurs biens; si s’en
partirent, et tantost li dus en envoia prendre le saisine
et le possession par ses mareschaus, monsigneur
Boucicau et monsigneur Jehan de Viane, mareschal
de Bourgongne. Et delivra li dus le chastiel à un escuier
30 de Biausse qui s’appelloit Phelippos de Chartres.
Cilz le prist en garde et quarante compagnons avoech
[140] li. Puis s’en parti li dus et toute li hos, et s’en vinrent
devant un aultre chastiel que on dist Chameroles.
Si le assegièrent ces gens d’armes tout environ,
car il siet en plain pays; et y fist on asseoir et drecier
5 les engiens qui estoient amené de Chartres. Cil
engien estoient grant durement, et en y avoit quatre
qui moult constraindirent et travillièrent chiaus de
le forterèce.
Or vous parlerons ossi un petit de monsigneur
10 Jehan de le Rivière qui tenoit siège devant Akegni,
assés priès de Passi, en le conté d’Evrues, et avoit en
se route bien deux mil combatans, car il estoit si
bien dou roy qu’il voloit: se li faisoit on ses finances
et ses delivrances à sa volenté. Ens ou chastiel
15 d’Akegni avoit Englès, Normans, François et Navarois,
qui là estoient retrait puis la bataille de Coceriel. Et
se tinrent et deffendirent cil le chastiel moult bien,
et ne les pooit on mies bien avoir à sen aise, car il
estoient bien pourveu d’artillerie et de vivres: pour
20 quoi il se tinrent plus longuement. Toutes fois finablement
il furent si mené et si apressé qu’il se rendirent,
salves leurs vies et leurs biens, et se partirent et se
retraisent dedens Cherebourch. Si prist messires Jehans
de la Rivière la saisine dou dit chastiel d’Akegni
25 et le rafreschi de nouvelles gens, et puis se desloga et
parti et toutes ses hos, et se traisent par devant la
ville et la cité d’Evrues. Si estoient avoecques lui et
de se carge messires Hues de Chasteillon, li sires de
Kauni, messires Mahieus de Roie, li sires de Montsaut,
30 li sires de Helli, li sires de Cresekes, li sires de Saintpi,
messires Oudars de Renti, messires Engherans du
Edins et pluiseur bon chevalier et escuier de France.
[141] Par dedens la cité d’Evrues estoient, pour le garder,
messires Guillaumes de Gauville et messires Legiers
d’Orgesi qui trop bien en songnièrent. Si avoient il
souvent l’assaut, mès il estoient si bien sus leur garde
5 qu’il n’en faisoient compte.

§ 527. Entrues que messires Jehans de le Rivière


et li dessus dit baron et chevalier de France seoient
devant la cité d’Evrues, li dus de Bourgongne apressa
si chiaus de Chamerolles qu’il ne peurent plus durer
10 et se rendirent simplement en le volenté dou duch.
Si furent pris à merci tout li saudoiier estragnier,
mès aucun pillars de le nation de France qui là s’estoient
bouté furent tout mort. Là vinrent en l’ost li
bourgois de Chartres et priièrent au duch de Bourgongne
15 qu’il leur volsist donner, pour le salaire de
leurs engiens, le chastiel de Chamerolles qui moult
les avoit heriiés et cuvriiés dou temps passé. Li dus
leur acorda et donna en don à faire ent leur volenté.
Tantost cil de Chartres misent ouvriers en oevre, et
20 abatirent et rasèrent tout par terre le dit chastiel: onques
n’i laissièrent pierre sur aultre.
Adonc se desloga li dis dus et passa oultre, et s’en
vint devant un autre chastiel que on dist Drue[s], qui
siet ou plain de le Biausse, et le tenoient pillart. Si
25 le conquisent li François par force, et furent tout
mort cil qui dedens estoient. Puis passèrent oultre et
s’en alèrent devant un aultre fort que on dist Preus:
si le assegièrent et environnèrent de tous costés, et y
livrèrent tamaint assaut, ançois que le peuissent
30 avoir. Finablement, cil de Preus se rendirent, salve
leurs corps, mais aultre cose il n’en portèrent:
[142] encores couvint il demorer en le prison dou dit duch,
en sa volenté, tous chiaus qui François estoient. Si
fist li dus de Bourgongne par ses mareschaus prendre
le saisine dou chastiel de Preus, et puis le donna à
5 un chevalier de Biausse que on appelloit messire
Pierre dou Bois Ruffin. Cilz le fist remparer et ordener
bien et à point, et le garda toutdis depuis bien et
souffissamment.
Apriès ces coses faites, li dus de Bourgongne et
10 une partie de ses gens s’en vinrent rafrescir en le cité
de Chartres. Quant il eurent là esté cinq jours, il
s’en partirent et se traisent par devant le chastiel de
Couvai, et le assegièrent de tous poins. Ceste garnison
de Couvai avoit fait moult de destourbiers ens
15 ou pays d’environ: pour tant se prendoit li dus de
Bourgongne plus priès comment il le peuist avoir, et
bien disoit qu’il ne s’en partiroit, si les aroit à sa
volenté, et avoit fait drecier par devant jusques à six
grans engiens qui jettoient ouniement à le forterèce
20 et moult le travilloient. Quant cil de Couvai veirent
que il estoient si apressé, si commencièrent à trettier,
et se fuissent volentiers rendu, salve leurs corps et
leurs biens; mais li dus n’i voloit entendre, se il ne
se rendoient simplement: ce que il n’euissent jamais
25 fait, car il savoient bien qu’il estoient tout mort
d’avantage.
Entrues que cil siège, ces prises, cil assaut et ces
chevaucies se faisoient en Biausse et en Normendie,
couroient d’autre part messires Loeis de Navare et
30 ses gens en le Basse Auvergne et en Berri, et y tenoient
les camps, et y honnissoient et apovrissoient
durement le pays, ne nulz n’aloit au devant. Et ossi
[143] chil de le Charité faisoient autour d’yaus che qu’il
voloient; dont les complaintes en venoient tous
les jours au roy de France. D’autre part, li contes
de Montbliar avoecques aucuns alliiés d’Alemagne
5 estoient entré en la ducé de Bourgongne par devers
Besençon, et y honnissoient ossi tout le pays: pour
quoi li rois de France eut conseil qu’il briseroit tous
ces sièges de Biausse et de Normendie, et envoieroit
le duch de Bourgongne son frère en son pays; car
10 bien y besongnoit. Si le manda incontinent qu’il desfesist
son siège et se retraisist devers Paris, car il le
couvenoit aler d’autre part, et se li segnefia clerement
l’afaire ensi qu’il aloit.
Quant li dus oy ces nouvelles, si fu tous pensieus,
15 tant pour son pays que on li ardoit, que
pour ce qu’il avoit parlé si avant dou siège de Couvai,
qu’il ne s’en partiroit si les aroit à sa volenté.
Si remoustra ce à son conseil, et trouva que, ou cas
que li rois le remandoit, qui là l’avoit envoiiet, il
20 s’en pooit bien partir sans fourfet, mais on n’en
fist nul samblant à chiaus de Couvai. Si leur fu demandé
des mareschaus se il se voloient rendre simplement.
Ils respondirent que nennil, mès volentiers
se renderoient, salve leurs corps et leurs biens.
25 Finablement, li dus vei que partir le couvenoit: si
les laissa passer parmi ce trettié, et rendirent le chastiel
de Couvai au dit duch, et s’en partirent, si com
chi dessus est dit. Si en prist li dus de Bourgongne
le saisine et le possession et puis le delivra à un escuier
30 de Biausse qui s’appelloit Phelippes d’Arcies.
Chilz le rempara bien et biel et le repourvei et rafreschi
de tous bons compagnons.
[144] Ce fait, li dus de Bourgongne et ses gens d’armes
s’en revinrent à Chartres. Si recarga li dus le plus grant
partie de ses gens au conte d’Auçoirre et au mareschal
Boucicau et à monsigneur Loeis de Sansoirre. Si se
5 parti et en mena avoecques lui monsigneur Loeis de
Chalon, le signeur de Biaugeu, monsigneur Jehan de
Viane et tous les Bourghignons. Et chevaucièrent
tant qu’il revinrent à Paris. Si passèrent oultre les
gens d’armes, sans point d’arrest, en alant devers
10 Bourgongne. Mès li dus s’en vint devers le roy son
frère, qui se tenoit à Vaus la Contesse en Brie, et là
fu il un jour tant seulement dalés lui et puis s’en
parti. Si esploita tant qu’il vint à Troies en Campagne,
et puis passa oultre et prist le chemin de Lengres,
15 et partout mandoit gens efforciement.
Et ja s’estoient cueilliet et pourveu li Bourghegnon
grandement et mis en frontière contre les ennemis.
Et là estoit li Archeprestres, sires de Chastielvillain, li
sires de Vregi, li sires de Grantsi, li sires de Sombrenon,
20 li sires de Rougemont, et uns moult riches et haulz
genlilz homs qui s’appelloit Jehans de Bourgongne,
li sires d’Epoises, messires Hughes de Viane, li sires
de Trichastiel et proprement li evesques de Lengres.
Si furent encores li baron et li chevalier de Bourgongne
25 moult resjoï, quant leurs sires fu venus. Si chevaucièrent
contre leurs ennemis, de quoi on disoit
bien que il estoient quinze cens lances, mais il n’osèrent
attendre, sitost que il sentirent la venue dou dit
duch et de ses gens. Si se retraisent arrière oultre le
30 Rin; mais li Bourghegnon ne se faindirent mies d’entrer
en le conté de Montbliar et en ardirent une
grant partie.

[145] § 528. Entrues que ceste chevaucie se fist en


Bourgongne, envoia li rois de France monsigneur
Moriel de Fiennes son connestable et ses deux mareschaus,
monsigneur Boucicau et monsigneur Mouton
5 de Blainville, et grant fuison de chevaliers et escuiers,
par devant la Charité sus Loire, liquel y misent
le siège, si tost comme il y furent venu, et le assegièrent
d’un costé bien et fortement. Si aloient li
compagnon, pour leurs corps avancier, priès que tous
10 les jours escarmucier à chiaus de dedens. Là y avoit
des apertises d’armes faites pluiseurs. Et y tinrent le
siège li dis connestables et li doi mareschal de France,
sans point partir jusques adonc que li dus de Bourgongne
et la plus grant partie de ses gens, qui avoient
15 chevaucié avoecques lui en le conté de Montbliar,
furent tout revenu en France devers le roy et le trouvèrent
à Paris.
Sitost que li dus de Bourgongne fu là revenus, li
dis rois l’envoia à plus de mil lances devant la
20 Charité. Ensi fu li sièges renforciés. Et se fist chiés
de toutes ces gens d’armes li dus de Bourgongne.
Et estoient bien li François à siège par devant la
Charité plus de trois mil lances, chevaliers et escuiers.
De quoi li pluiseur se aloient souvent enventurer
25 et escarmucier à chiaus de le garnison. Si
en y avoit des navrés des uns et des aultres. Et là
furent fait chevalier et levèrent banière, à une sallie
que chil de le Charité fisent hors, messires Robers
d’Alençon, filz au conte d’Alençon qui demora à
30 Creci, et messires Loeis d’Auçoirre, filz au conte
d’Auçoirre et frères au conte d’Auçoirre qui là estoit
presens. Si furent durement li compagnon de le
[146] Charité apressé, et se fuissent volentiers parti par
composition se il peuissent; mès li dus de Bourgongne
n’i voloit entendre, se il ne se rendoient simplement.
5 En ce temps, estoit sus le marce d’Auvergne,
messires Loeis de Navare qui destruisoit et ardoit
ossi là à ce lés tout le pays, et assambloit et prioit
gens de tous costés pour venir secourir ses gens de
le Charité; car volentiers ewist levé le siège, et avoit
10 bien deux mil combatans. Et avoit li dis messires
Loeis de Navare envoiiet en Bretagne devers monsigneur
Robert Canolle et monsigneur Gautier Huet
et monsigneur Mahieu de Gournay et aucuns chevaliers
et escuiers qui là estoient dalés le conte de
15 Montfort, en priant que il se volsissent prendre priès
de lui venir servir, et que sans faute il iroit combatre
les François qui gisoient assés esparsement devant
la Charité. Chil chevalier d’Engleterre i desiroient
moult à aler; mès, en ce temps, seoit li dis
20 contes de Montfort devant le fort chastiel d’Auroy
en Bretagne, que li rois Artus fist jadis fonder, et
avoit juré qu’il ne s’en partiroit si l’aroit pris et conquis
à sa volenté. Avoech tout ce, il entendoit que
messires Charles de Blois estoit en France et pourcachoit
25 devers le roi de France à avoir gens d’armes
pour venir lever le siège et yaus combatre. Si ne
laissoit mies volentiers ces chevaliers et escuiers
d’Engleterre partir de lui, car il ne savoit quel besongne
il en aroit; mès en mandoit et en prioit tous les
30 jours là où il en pensoit à avoir et à recouvrer, tant
en Engleterre comme en la ducé d’Aquitainne.

[147] § 529. On voet bien dire et maintenir que cil qui


estoient en garnison en le Charité sus Loire, euissent
eu fort temps; car li dus de Bourgongne, qui tenoit
par devant toute la fleur de le chevalerie de France,
5 les avoit ja durement apressés et tolut le rivière, que
nulles pourveances ne leur pooient venir. Si en estoient
li compagnon durement esbahi; car messires
Loeis de Navare, où leur esperance de reconfort
gisoit, estoit retrès et s’en raloit en Normendie devers
10 Chierebourch, par l’ordenance et avis dou roy son
frère. Mès che que messires Charles de Blois estoit
pour le temps dalés le roy de Franche son cousin, et
li remoustroit pluiseurs voies de raison où li rois se
sentoit grandement tenus de lui aidier contre le conte
15 de Montfort, et faire le voloit, si en chei trop bien à
chiaus de le Charité sus Loire; car, ensi que je vous
ay dit comment il estoient apressé, li rois de France,
pour deffaire ce siège, afin que messires Charles de
Blois euist plus de gens d’armes, manda au duch de
20 Bourgongne son frère, que il presist chiaus de le
Charité en trettié et les laiast passer, parmi tant qu’il
rendesissent le forterèce et qu’il jurassent ossi solennelment
que, dedens trois ans, pour le fait dou roy
de Navare ne s’armeroient.
25 Quant li dus vei le mandement dou roy son frère,
si fist remoustrer par ses mareschaus as chapitainnes
de le Charité, le trettié par où il pooient venir et
descendre à acord. Cil de le Charité, qui se veoient
en bien perilleus parti, y entendirent volentiers, et
30 jurèrent solennelment à yaus non armer contre le
royaume de France, le terme de trois ans, pour le
fait dou roy de Navare. Parmi tant, on les laissa
[148] paisieulement partir; mais il n’enportèrent riens dou
leur, et s’en alèrent la plus grant partie tout à piet,
et passèrent parmi le royaume de France, sus le
conduit dou duc de Bourgongne. Ensi reconquisent
5 li François le ville de la Charité sus Loire, et y revinrent
cil [et celles[429]] de le nation qui vuidié en estoient
et ailleurs alé demorer; et se deffist li sièges,
et retourna li dus de Bourgongne arrière en France,
et en remena tous ses Bourghegnons, dont il avoit
10 grant plenté.
Or vous parlerons de monsigneur Charlon de
Blois, comment il persevera, et d’une grant assamblée
de gens d’armes qu’il mist sus et amena en Bretagne,
et de monsigneur Jehan de Montfort, comment
15 il se pourvei ossi à l’encontre.
§ 530. Li rois de France acorda à son cousin, monsigneur
Charle de Blois, que il euist de son royaume
jusques à mil lances, et escrisi à monsigneur Bertran
de Claiekin, qui estoit en Normendie, que il s’en
20 alast en Bretagne pour aidier et conforter monsigneur
Charle de Blois contre monsigneur Jehan de Montfort.
De ces nouvelles fu li dis messires Bertrans
moult resjoïs, car il avoit toutdis tenu le dit monsigneur
Charle pour son naturel signeur. Si se parti
25 de Normendie à tout che que il avoit de Bretons et
chevauça devers Tours en Tourainne pour aler en
Bretagne. Et messires Boucicaus, mareschaus de
France, s’en vint en Normendie en son lieu tenir le
frontière. Tant esploita li dis messires Bertrans et
[149] se route que il vint à Nantes en Bretagne, et là
trouva le dit monsigneur Charle et madame sa fame
qui le rechurent liement et doucement, et li sceurent
très grant gré de ce qu’il estoit ensi venus. Et
5 eurent là parlement ensamble, comment il se maintenroient;
car ossi y estoient li grigneur partie des
barons de Bretagne, et avoient tout pourpos et affection
de aidier monsigneur Charle, et le tenoient
tout à duc et à signeur. Et pour venir lever le siège
10 de devant Auroy et combatre monsigneur Jehan de
Montfort, ne demorèrent lons jours que grant baronnie
et chevalerie de France et de Normendie vinrent,
li contes d’Auçoirre, li contes de Joni, li sires de
Friauville, li sires de Prie, li Bèghes de Vellainnes et
15 pluiseur bon chevalier et escuier, tout d’une sorte
et droite gens d’armes.
Ces nouvelles vinrent à monsigneur Jehan de Montfort
qui tenoit son siège devant Auroy, que messires
Charles de Blois faisoit grant amas de gens d’armes, et
20 que grant fuison de signeurs de France li estoient venu
et venoient encores tous les jours, avoecques l’ayde
et confort qu’il avoit encores des barons, chevaliers et
escuiers de la ducé de Bretagne. Sitost que messires
Jehans de Montfort entendi ces nouvelles, il le segnefia
25 fiablement en la ducé d’Aquitainne as chevaliers
et escuiers d’Engleterre qui là se tenoient, et
especialment à monsigneur Jehan Chandos, en lui
priant chierement que à che grant besoing il le volsist
venir conforter et consillier, et que il apparoit
30 en Bretagne uns biaus fais d’armes, auquel tout signeur,
chevalier et escuier, pour leur honneur avanchier,
devoient volentiers entendre. Quant messires
[150] Jehans Chandos se vei priiés si affectueusement dou
conte de Montfort, si en parla à son signeur le prince
de Galles, à savoir que bon en estoit à faire. Li princes
li respondi qu’il y pooit bien aler sans nul fourfet;
5 car ja faisoient li François partie contre le dit conte
en l’ocquison de monsigneur Charle de Blois, et qu’il
l’en donnoit bon congiet.
De ces nouvelles fu li dis messires Jehans Chandos
moult liés, et se pourvei bien et grandement et pria
10 pluiseurs chevaliers et escuiers de la ducé d’Acquitainnes;
mès trop petit en alèrent avoecques lui, se il
n’estoient Englès. Toutesfois il enmena bien deux
cens lances et otant d’arciers, et chevauça tant parmi
Poito et Saintonge, qu’il entra en Bretagne et vint au
15 siège devant Auroy. Et là trouva il le conte de Montfort
qui le recheut liement et grandement, et fu moult
resjoïs de sa venue: ossi furent proprement messires
Oliviers de Cliçon, messires Robers Canolles et li aultre
compagnon; et leur sambloit proprement et generaument
20 que nulz maulz ne leur pooit avenir, puisqu’il
avoient monsigneur Jehan Chandos en leur compagnie.
Si passèrent le mer [hastivement[430]] d’Engleterre
en Bretagne pluiseur chevalier et escuier qui desiroient
leurs corps à avancier et yaus combattre as
25 François, et vinrent par devant Auroy, en l’ayde dou
conte de Montfort, qui tout les rechut à grant joie.
Si estoient bien Englès et Breton, quant il furent
tout assamblé, seize cens combatans, chevaliers et
escuiers et gens d’armes, et environ huit cens ou
30 neuf cens arciers.

[151] § 531. Nous revenrons à monsigneur Charle de


Blois qui se tenoit en la bonne cité de Nantes et là
faisoit son amas et son mandement de chevaliers et
escuiers de toutes pars, là où il en pensoit à recouvrer
5 par priière, car bien estoit enfourmés que li
contes de Montfort estoit durement fors et bien reconfortés
d’Englès. Si prioit les barons, les chevaliers
et les escuiers de Bretagne, dont il avoit
eus et recheus les hommages, que il li vosissent aidier
10 à garder et à deffendre son hyretage contre ses
ennemis. Si vinrent des barons de Bretagne, pour lui
servir et à son mandement, li viscontes de Rohem, li
sires de Lyon, messires Charles de Dignant, li sires
de Rays, li sires de Rieus, li sires de Tournemine, li
15 sires d’Ansenis, li sires de Malatrait, li sires de Kintin,
li sires d’Avaugor, li sires de Rocefort, li sires de
Gargoulé, li sires de Lohiac, li sires dou Pont et
moult d’aultres que je ne puis mies tous nommer. Si
se logièrent cil signeur et leurs gens en le cité de
20 Nantes et ens ès villages d’environ. Quant il furent
tout assamblé, on les esma à vingt cinq cens lances
parmi chiaus qui estoient venu de France. Si ne veurent
point ces gens d’armes là faire trop lontain sejour,
mais consillièrent à monsigneur Charle de Blois
25 de chevaucier par devers les ennemis.
Au departement et au congiet prendre, madame la
femme à monsigneur Charle de Blois dist à son mari,
present monsigneur Bertran de Claiekin et aucuns
barons de Bretagne: «Monsigneur, vous en alés deffendre
30 et garder mon hiretage et le vostre, car ce qui
est mien est vostre, lequel messires Jehans de Montfort
nous empeece et a empeechiet un grant temps à
[152] tort et sans cause: ce set Dieus et li baron de Bretagne
qui chi sont comment j’en sui droite hiretière.
Si vous pri chierement que, sus nulle ordenance ne
composition ne trettié d’acort ne voeilliés descendre
5 que li corps de la ducé ne nous demeure.» Et ses maris
li eut en couvent. Adonc se parti, et se partirent
tout li baron et li signeur qui là estoient, et prisent
congiet à leur dame qu’il tenoient pour duçoise. Si
se aroutèrent et acheminèrent ces gens d’armes et
10 ces hos par devers Rennes et tant esploitièrent qu’il
y parvinrent. Si se logièrent dedens la cité de Rennes
et environ et s’i reposèrent et rafreschirent, pour
aprendre et mieulz entendre dou couvenant de leurs
ennemis.

15 § 532. Entre Rennes et Auroy, là où messires Jehans


de Montfort seoit, à huit liewes de pays. Si
vinrent ces nouvelles au dit siège que messires Charles
de Blois approçoit durement et avoit la plus belle
gent d’armes, les mieulz ordenés et armés que on
20 euist onques mès veus issir de France. De ces nouvelles
furent li plus des Englès qui là estoient, qui
desiroient à combatre, tout joiant. Si commencièrent
cil compagnon à mettre leurs armeures à point et à
refourbir leurs lances, leurs daghes, leurs haces, leurs
25 plates, haubregons, hyaumes, bachinés, visières, espées
et toutes manières de harnas, car bien pensoient
qu’il en aroient mestier et qu’il se combateroient.
Adonc se traisent en conseil les chapitainnes
de l’host, li contes de Montfort premierement, messires
30 Jehans Chandos, par lequel conseil en partie il
voloit user, messires Robers Canolles, messires
[153] Ustasses d’Aubrecicourt, messires Hues de Cavrelée,
messires Gautiers Hués, messires Mahieus de Gournay
et li aultre. Si regardèrent et considerèrent cil
baron et cil chevalier, par le conseil de l’un et de
5 l’autre et par grant avis, qu’il se retrairoient au matin
hors de leurs logeis, et prenderoient terre et place
sus les camps, et là aviseroient de tous assens, pour
mieus avoir ent le cognissance. Si fu ensi nonciet et
segnefiiet parmi leur host que cescuns fust à l’endemain
10 appareilliés et mis en arroi et en ordenance de
bataille, ensi que pour tantost combatre. Ceste nuit
passa: l’endemain vint, qui fu par un samedi, que li
Englès et Breton d’une sorte issirent hors de leurs
logeis et s’en vinrent moult faiticement et ordeneement
15 ensus dou dit chastiel d’Auroy, et prisent place
et terre et distrent et affremèrent entre yaus que là
attenderoient il leurs ennemis.
Droitement ensi que entours heure de prime,
messires Charles de Blois et toute sen host vinrent,
20 qui s’estoient parti le venredi apriès boire de la cité
de Rennes, et avoient celle nuit jëu à trois petites
liewes priès d’[Auroy]. Et estoient les gens à monsigneur
Charlon de Blois le mieus ordené et le plus
faiticement et mis en milleur couvenant que on
25 peuist veoir ne deviser. Et chevauçoient si serré que
on ne peuist jetter un estuef que il ne cheist sus
pointe de glave, tant les portoient il proprement roides
et contremont. De yaus veoir et regarder proprement,
li Englès gens d’onneur y prendoient grant
30 plaisance. Si se arrestèrent li François, sans yaus desroyer,
devant leurs ennemis, et prisent terre entre
grans bruières; et fu commandé de par leur mareschal
[154] que nulz n’alast avant sans commandement ne
fesist course, jouste ne empainte. Si se arrestèrent
toutes gens d’armes, et se misent en arroi et en bon
couvenant ensi que pour tantos combatre, car il
5 n’esperoient aultre cose et en avoient grant desir.

§ 533. Messires Charles de Blois, par le conseil


de monsigneur Bertran de Claiekin, qui estoit là uns
grans chiés et moult creus et alosés des barons de
Bretagne, ordonna ses batailles, et en fist trois et
10 une arrière garde. Et me samble que messires Bertrans
eut le première, avoecques grant fuison de bons
chevaliers et escuiers de Bretagne. La seconde eurent
li contes d’Auçoirre et li contes de Joni, avoecques
grant fuison de bons chevaliers et escuiers de France.
15 Et la tierce eut et la grigneur partie messires Charles
de Blois, et en sa compagnie pluiseurs haus barons de
Bretagne. Et estoient dalés lui li viscontes de Rohem,
li sires de Lyon, li sires d’Avaugor, messires Charles
de Dignant, li sires d’Ansenis, li sires de Malatrait et
20 pluiseur aultre. En l’arrière garde estoient li sires de
Rais, li sires de Rieus, li sires de Tournemine, li sires
dou Pont et moult d’aultres bons chevaliers et escuiers,
et avoit en çascune de ces batailles bien mil
combatans. Là aloit messires Charles de Blois de bataille
25 en bataille amonester et priier çascun moult
bellement et doucement, qu’il volsissent estre loyal
et preudomme et bon combatant; et retenoit sus
s’ame et sa part de paradys, que ce seroit sus son
bon et juste droit que on se combateroit. Là li
30 avoient tout en couvent li un par l’autre que si bien
s’en acquitteroient qu’il leur en saroit gré. Or vous
[155] parlerons dou couvenant des Englès et des Bretons
de l’autre costé, et comment il ordonnèrent leurs
batailles.

§ 534. Messires Jehans Chandos, qui estoit chapitains

You might also like