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

Functional Data Structures in R: Advanced Statistical Programming in R Mailund pdf download

The document discusses 'Functional Data Structures in R' by Thomas Mailund, which introduces the concept of functional data structures in the R programming language. It highlights the challenges of mutable data structures in traditional programming and presents alternatives for implementing data structures in R. The book covers various topics including abstract data structures, persistent data, and algorithmic programming techniques suitable for R.

Uploaded by

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

Functional Data Structures in R: Advanced Statistical Programming in R Mailund pdf download

The document discusses 'Functional Data Structures in R' by Thomas Mailund, which introduces the concept of functional data structures in the R programming language. It highlights the challenges of mutable data structures in traditional programming and presents alternatives for implementing data structures in R. The book covers various topics including abstract data structures, persistent data, and algorithmic programming techniques suitable for R.

Uploaded by

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

Functional Data Structures in R: Advanced

Statistical Programming in R Mailund download

https://textbookfull.com/product/functional-data-structures-in-r-
advanced-statistical-programming-in-r-mailund/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Functional Data Structures in R: Advanced Statistical


Programming in R Thomas Mailund

https://textbookfull.com/product/functional-data-structures-in-r-
advanced-statistical-programming-in-r-thomas-mailund/

Functional Programming in R: Advanced Statistical


Programming for Data Science, Analysis and Finance 1st
Edition Thomas Mailund

https://textbookfull.com/product/functional-programming-in-r-
advanced-statistical-programming-for-data-science-analysis-and-
finance-1st-edition-thomas-mailund/

Domain Specific Languages in R Advanced Statistical


Programming 1st Edition Thomas Mailund

https://textbookfull.com/product/domain-specific-languages-in-r-
advanced-statistical-programming-1st-edition-thomas-mailund/

Domain Specific Languages in R Advanced Statistical


Programming 1st Edition Thomas Mailund

https://textbookfull.com/product/domain-specific-languages-in-r-
advanced-statistical-programming-1st-edition-thomas-mailund-2/
Metaprogramming in R: Advanced Statistical Programming
for Data Science, Analysis and Finance 1st Edition
Thomas Mailund

https://textbookfull.com/product/metaprogramming-in-r-advanced-
statistical-programming-for-data-science-analysis-and-
finance-1st-edition-thomas-mailund/

Advanced Object-Oriented Programming in R: Statistical


Programming for Data Science, Analysis and Finance 1st
Edition Thomas Mailund

https://textbookfull.com/product/advanced-object-oriented-
programming-in-r-statistical-programming-for-data-science-
analysis-and-finance-1st-edition-thomas-mailund/

Advanced R Statistical Programming and Data Models:


Analysis, Machine Learning, and Visualization 1st
Edition Matt Wiley

https://textbookfull.com/product/advanced-r-statistical-
programming-and-data-models-analysis-machine-learning-and-
visualization-1st-edition-matt-wiley/

Advanced linear modeling statistical learning and


dependent data 3rd Edition Christensen R

https://textbookfull.com/product/advanced-linear-modeling-
statistical-learning-and-dependent-data-3rd-edition-
christensen-r/

Advanced R: Data Programming and the Cloud 1st Edition


Matt Wiley

https://textbookfull.com/product/advanced-r-data-programming-and-
the-cloud-1st-edition-matt-wiley/
Functional Data

Structures in R

Advanced Statistical Programming in R

Thomas Mailund
Functional Data

Structures in R

Advanced Statistical

Programming in R

Thomas Mailund

Functional Data Structures in R: Advanced Statistical

Programming in R

Thomas Mailund

Aarhus N, Denmark

ISBN-13 (pbk): 978-1-4842-3143-2

ISBN-13 (electronic): 978-1-4842-3144-9

https://doi.org/10.1007/978-1-4842-3144-9

Library of Congress Control Number: 2017960831

Copyright © 2017 by Thomas Mailund

This work is subject to copyright. All rights are reserved by the


Publisher, whether the whole or part of the material is concerned,
specifically the rights of translation, reprinting, reuse of illustrations,
recitation, broadcasting, reproduction on microfilms or in any other
physical way, and transmission or information storage and retrieval,
electronic adaptation, computer software, or by similar or dissimilar
methodology now known or hereafter developed.

Trademarked names, logos, and images may appear in this book.


Rather than use a trademark symbol with every occurrence of a
trademarked name, logo, or image we use the names, logos, and
images only in an editorial fashion and to the benefit of the
trademark owner, with no intention of infringement of the trademark.

The use in this publication of trade names, trademarks, service


marks, and similar terms, even if they are not identified as such, is
not to be taken as an expression of opinion as to whether or not they
are subject to proprietary rights.

While the advice and information in this book are believed to be true
and accurate at the date of publication, neither the authors nor the
editors nor the publisher can accept any legal responsibility for any
errors or omissions that may be made. The publisher makes no
warranty, express or implied, with respect to the material contained
herein.

Cover image by Freepik (www.freepik.com)

Managing Director: Welmoed Spahr

Editorial Director: Todd Green

Acquisitions Editor: Steve Anglin

Development Editor: Matthew Moodie

Technical Reviewer: Karthik Ramasubramanian

Coordinating Editor: Mark Powers

Copy Editor: Corbin P Collins

Distributed to the book trade worldwide by Springer


Science+Business Media New York, 233 Spring Street, 6th Floor, New
York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail
[email protected], or visit www.springeronline.com.
Apress Media, LLC is a California LLC and the sole member (owner) is
Springer Science + Business Media Finance Inc (SSBM Finance Inc).
SSBM Finance Inc is a Delaware corporation.

For information on translations, please e-mail [email protected], or


visit www.apress.com/

rights-permissions.

Apress titles may be purchased in bulk for academic, corporate, or


promotional use. eBook versions and licenses are also available for
most titles. For more information, reference our Print and eBook Bulk
Sales web page at www.apress.com/bulk-sales.

Any source code or other supplementary material referenced by the


author in this book is available to readers on GitHub via the book's
product page, located at www.apress.com/

9781484231432. For more detailed information, please visit


www.apress.com/source-code.

Printed on acid-free paper

Table of Contents

About the Author vii

About the Technical Reviewer ix

Introduction xi

Chapter 1: Introduction1

Chapter 2: Abstract Data Structures 3

Structure on Data
�������������������������������
�������������������������������
�������������������������������
�����4

Abstract Data Structures in R


�������������������������������
�������������������������������
�����������������6

Implementing Concrete Data Structures in R


�������������������������������
�������������������������9

Asymptotic Running Time


�������������������������������
�������������������������������
���������������������11

Experimental Evaluation of Algorithms


�������������������������������
�������������������������������
�15

Chapter 3: Immutable and Persistent Data 25

Persistent Data Structures


�������������������������������
�������������������������������
��������������������26

List Functions
�������������������������������
�������������������������������
�������������������������������
���������28

Trees
�������������������������������
�������������������������������
�������������������������������
����������������������37

Random Access Lists


�������������������������������
�������������������������������
����������������������������56

Chapter 4: Bags, Stacks, and Queues 67

Bags
�������������������������������
�������������������������������
�������������������������������
�����������������������68

Stacks
�������������������������������
�������������������������������
�������������������������������
��������������������73

Queues
�������������������������������
�������������������������������
�������������������������������
�������������������74

Side Effects Through Environments


�������������������������������
�������������������������������7
7

Side Effects Through Closures


�������������������������������
�������������������������������
���������79

iii

Table of Con

able of Con enT

en s

A Purely Functional Queue


�������������������������������
�������������������������������
��������������82

Time Comparisons
�������������������������������
�������������������������������
���������������������������84

Amortized Time Complexity and Persistent Data Structures


�������������������������85

Double-Ended Queues
�������������������������������
�������������������������������
���������������������87

Lazy Queues
�������������������������������
�������������������������������
�������������������������������
�����������95
Implementing Lazy Evaluation
�������������������������������
�������������������������������
���������96

Lazy Lists
�������������������������������
�������������������������������
�������������������������������
����������98

Amortized Constant Time, Logarithmic Worst-Case, Lazy Queues


���������������107

Constant Time Lazy Queues


�������������������������������
�������������������������������
����������118

Explicit Rebuilding Queue


�������������������������������
�������������������������������
��������������124

Chapter 5: Heaps 135

Leftist Heaps
�������������������������������
�������������������������������
�������������������������������
��������140

Binomial Heaps
�������������������������������
�������������������������������
�������������������������������
����144
Splay Heaps
�������������������������������
�������������������������������
�������������������������������
���������157

Plotting Heaps
�������������������������������
�������������������������������
�������������������������������
������178

Heaps and Sorting


�������������������������������
�������������������������������
�������������������������������1
83

Chapter 6: Sets and Search Trees 189

Search Trees
�������������������������������
�������������������������������
�������������������������������
��������190

Red-Black Search Trees


�������������������������������
�������������������������������
����������������������192

Insertion
�������������������������������
�������������������������������
�������������������������������
���������195
Deletion
�������������������������������
�������������������������������
�������������������������������
����������203

Visualizing Red-Black Trees


�������������������������������
�������������������������������
����������226

Splay Trees
�������������������������������
�������������������������������
�������������������������������
�����������231

iv

Table of Con

able of Con enTs

Conclusions 247

Acknowledgements�����������������������
�������������������������������
�������������������������������
������248

Bibliography 249

Index 251
v

About the Author

Thomas Mailund is an associate professor in bioinformatics at


Aarhus University, Denmark. He has a background in math and
computer science.

For the last decade, his main focus has been on genetics and
evolutionary studies, particularly comparative genomics, speciation,
and gene flow between emerging species. He has published
Beginning Data Science in R, Functional Programming in R, and
Metaprogramming in R with Apress, as well as other books.

vii

About the Technical Reviewer

Karthik Ramasubramanian works for one

of the largest and fastest- growing technology

unicorns in India, Hike Messenger, where

he brings the best of business analytics


and data science experience to his role. In

his seven years of research and industry

experience, he has worked on cross- industry

data science problems in retail, e-commerce,

and technology, developing and prototyping

data-driven solutions. In his previous role at Snapdeal, one of the


largest e-commerce retailers in India, he was leading core statistical
modeling initiatives for customer growth and pricing analytics. Prior
to Snapdeal, he was part of the central database team, managing the
data warehouses for global business applications of Reckitt Benckiser
(RB). He has vast experience working with scalable machine learning
solutions for industry, including sophisticated graph network and self-
learning neural networks.

He has a master’s degree in theoretical computer science from PSG


College of Technology, Anna University, and is a certified big data
professional. He is passionate about teaching and mentoring future
data scientists through different online and public forums. He enjoys
writing poems in his leisure time and is an avid traveler.

ix

Introduction

This book gives an introduction to functional data structures. Many


traditional data structures rely on the structures being mutable. We
can update search trees, change links in linked lists, and rearrange
values in a vector. In functional languages, and as a general rule in
the R programming language, data is not mutable. You cannot alter
existing data. The techniques used to modify data structures to give
us efficient building blocks for algorithmic programming cannot be
used.
There are workarounds for this. R is not a pure functional language,
and we can change variable-value bindings by modifying
environments.

We can exploit this to emulate pointers and implement traditional


data structures this way; or we can abandon pure R programming
and implement data structures in C/C++ with some wrapper code so
we can use them in our R programs. Both solutions allow us to use
traditional data structures, but the former gives us very untraditional
R code, and the latter has no use for those not familiar with other
languages than R.

The good news, though, is that we don’t have to reject R when


implementing data structures if we are willing to abandon the
traditional data structures instead. There are data structures that we
can manipulate by building new versions of them rather than
modifying them. These data structures, so-called functional data
structures, are different from the traditional data structures you
might know, but they are worth knowing if you plan to do serious
algorithmic programming in a functional language such as R.

There are not necessarily drop-in replacements for all the data
structures you are used to, at least not with the same runtime
performance for their operations, but there are likely to be
implementations for most xi

InT

In roduCTIon

CTI

abstract data structures you regularly use. In cases where you might
have to lose a bit of efficiency by using a functional data structures
instead of a traditional one, however, you have to consider whether
the extra speed is worth the extra time you have to spend
implementing a data structure in exotic R or in an entirely different
language.

There is always a trade-off when it comes to speed. How much


programming time is a speed-up worth? If you are programming in R,
chances are you value programmer-time over computer-time. R is a
high-level language and relatively slow compared to most other
languages.

There is a price to providing higher levels of expressiveness. You


accept this when you choose to work with R. You might have to make
the same choice when it comes to selecting a functional data
structure over a traditional one, or you might conclude that you really
do need the extra speed and choose to spend more time
programming to save time when doing an analysis. Only you can
make the right choice based on your situation. You need to find out
the available choices to enable you to work data structures when you
cannot modify them.

xii

CHAPTER 1

Introduction

This book gives an introduction to functional data structures. Many


traditional data structures rely on the structures being mutable. We
can update search trees, change links in linked lists, and rearrange
values in a vector. In functional languages, and as a general rule in
the R

programming language, data is not mutable. You cannot alter


existing data.

The techniques used to modify data structures to give us efficient


building blocks for algorithmic programming cannot be used.
There are workarounds for this. R is not a pure functional language,
and we can change variable-value bindings by modifying
environments.

We can exploit this to emulate pointers and implement traditional


data structures this way; or we can abandon pure R programming
and implement data structures in C/C++ with some wrapper code so
we can use them in our R programs. Both solutions allow us to use
traditional data structures, but the former gives us very untraditional
R code, and the latter has no use for those not familiar with other
languages than R.

The good news, however, is that we don’t have to reject R when


implementing data structures if we are willing to abandon the
traditional data structures instead. There are data structures we can
manipulate by building new versions of them rather than modifying
them. These data structures, so-called functional data structures, are
different from the traditional data structures you might know, but
they are worth knowing if you plan to do serious algorithmic
programming in a functional language such as R.

© Thomas Mailund 2017

T. Mailund, Functional Data Structures in R,


https://doi.org/10.1007/978-1-4842-3144-9_1

Chapter 1 IntroduCtIon

There are not necessarily drop-in replacements for all the data
structures you are used to, at least not with the same runtime
performance for their operations—but there are likely to be
implementations for most abstract data structures you regularly use.
In cases where you might have to lose a bit of efficiency by using a
functional data structure instead of a traditional one, you have to
consider whether the extra speed is worth the extra time you have to
spend implementing a data structure in exotic R or in an entirely
different language.

There is always a trade-off when it comes to speed. How much


programming time is a speed-up worth? If you are programming in R,
the chances are that you value programmer time over computer time.
R

is a high-level language that is relatively slow compared to most


other languages. There is a price to providing higher levels of
expressiveness.

You accept this when you choose to work with R. You might have to
make the same choice when it comes to selecting a functional data
structure over a traditional one, or you might conclude that you really
do need the extra speed and choose to spend more time
programming to save time when doing an analysis. Only you can
make the right choice based on your situation. You need to find out
the available choices to enable you to work data structures when you
cannot modify them.

CHAPTER 2

Abstract Data

Structures

Before we get started with the actual data structures, we need to get
some terminologies and notations in place. We need to agree on
what an abstract data structure is—in contrast to a concrete one—
and we need to agree on how to reason with runtime complexity in
an abstract way.

If you are at all familiar with algorithms and data structures, you can
skim quickly through this chapter. There won’t be any theory you are
not already familiar with. Do at least skim through it, though, just to
make sure we agree on the notation I will use in the remainder of the
book.

If you are not familiar with the material in this chapter, I urge you to
find a text book on algorithms and read it. The material I cover in
this chapter should suffice for the theory we will need in this book,
but there is a lot more to data structures and complexity than I can
possibly cover in a single chapter. Most good textbooks on algorithms
will teach you a lot more, so if this book is of interest, you should not
find any difficulties in continuing your studies.

© Thomas Mailund 2017

T. Mailund, Functional Data Structures in R,


https://doi.org/10.1007/978-1-4842-3144-9_2

Chapter 2 abstraCt Data struCtures

Structure on Data

As the name implies, data structures have something to do with


structured data. By data, we can just think of elements from some
arbitrary set. There might be some more structure to the data than
the individual data points, and when there is we keep that in mind
and will probably want to exploit that somehow. However, in the most
general terms, we just have some large set of data points.

So, a simple example of working with data would be imagining we


have this set of possible values—say, all possible names of students
at a university—and I am interested in a subset—for example, the
students that are taking one of my classes. A class would be a subset
of students, and I could represent it as the subset of student names.
When I get an email from a student, I might be interested in figuring
out if it is from one of my students, and in that case, in which class.
So, already we have some structure on the data. Different classes are
different subsets of student names. We also have an operation we
would like to be able to perform on these classes: checking
membership.

There might be some inherent structure to the data we work with,


which could be properties such as lexicographical orders on names—
it enables us to sort student names, for example. Other structure we
add on top of this. We add structure by defining classes as subsets of
student names. There is even a third level of structure: how we
represent the classes on our computer.

The first level of structure—inherent in the data we work with—is not


something we have much control over. We might be able to exploit it
in various ways, but otherwise, it is just there. When it comes to
designing algorithms and data structures, this structure is often
simple information; if there is order in our data, we can sort it, for
example. Different algorithms and different data structures make
various assumptions about the underlying data, but most general
algorithms and data structures make few assumptions. When I make
assumptions in this book, I will make those assumptions explicit.

Chapter 2 abstraCt Data struCtures

The second level of structure—the structure we add on top of the


universe of possible data points—is information in addition to what
just exists out there in the wild; this can be something as simple as
defining classes as subsets of student names. It is structure we add
to data for a purpose, of course. We want to manipulate this
structure and use it to answer questions while we evaluate our
programs. When it comes to algorithmic theory, what we are mainly
interested in at this level is which operations are possible on the data.
If we represent classes as sets of student names, we are interested
in testing membership to a set. To construct the classes, we might
also want to be able to add elements to an existing set. That might
be all we are interested in, or we might also want to be able to
remove elements from a set, get the intersection or union of two
sets, or do any other operation on sets.

What we can do with data in a program is largely defined by the


operations we can do on structured data; how we implement the
operations is less important. That might affect the efficiency of the
operations and thus the program, but when it comes to what is
possible to program and what is not—or what is easy to program and
what is hard, at least—it is the possible operations that are
important.

Because it is the operations we can do on data, and now how we


represent the data—the third level of structure we have—that is most
important, we distinguish between the possible operations and how
they are implemented. We define abstract data structures by the
operations we can do and call different implementations of them
concrete data structures. Abstract data structures are defined by
which operations we can do on data; concrete data structures, by
how we represent the data and implement these operations.

Chapter 2 abstraCt Data struCtures

Abstract Data Structures in R

If we define abstract data structures by the operations they provide,


it is natural to represent them in R by a set of generic functions. In
this book, I will use the S3 object system for this. 1

Let’s say we want a data structure that represents sets, and we need
two operations on it: we want to be able to insert elements into the
set, and we want to be able to check if an element is found in the
set. The generic interface for such a data structure could look like
this:
insert <- function(set, elem) UseMethod("insert") member <-
function(set, elem) UseMethod("member") Using generic
functions, we can replace one implementation with another with little
hassle. We just need one place to specify which concrete
implementation we will use for an object we will otherwise only
access through the abstract interface. Each implementation we write
will have one function for constructing an empty data structure. This
empty structure sets the class for the concrete implementation, and
from here on we can access the data structure through generic
functions. We can write a simple list-based implementation of the set
data structure like this: empty_list_set <- function() {

structure(c(), class = "list_set")

insert.list_set <- function(set, elem) {

structure(c(elem, set), class = "list_set")

1 If you are unfamiliar with generic functions and the S3 system, you
can check out my book Advanced Object-Oriented Programming in R
book (Apress, 2017), where I explain all this.

Chapter 2 abstraCt Data struCtures

member.list_set <- function(set, elem) {

elem %in% set

The empty_list_set function is how we create our first set of the


concrete type. When we insert elements into a set, we also get the
right type back, but we shouldn’t call insert.list_set directly. We
should just use insert and let the generic function mechanism pick
the right implementation. If we make sure to make the only point
where we refer to the concrete implementation be the creation of the
empty set, then we make it easier to replace one implementation
with another: s <- empty_list_set()

member(s, 1)

## [1] FALSE

s <- insert(s, 1)

member(s, 1)

## [1] TRUE

When we implement data structures in R, there are a few rules of


thumb we should follow, and some are more important than others.

Using a single “empty data structure” constructor and otherwise


generic interfaces is one such rule. It isn’t essential, but it does make
it easier to work with abstract interfaces.

More important is this rule: keep modifying and querying a data


structure as separate functions. Take an operation such as popping
the top element of a stack. You might think of this as a function that
removes the first element of a stack and then returns the element to
you. There is nothing wrong with accessing a stack this way in most
languages, but in functional languages, it is much better to split this
into two different operations: one for getting the top element and
another for removing it from the stack.

Chapter 2 abstraCt Data struCtures


The reason for this is simple: our functions can’t have side effects. If
a

“pop” function takes a stack as an argument, it cannot modify this


stack. It can give you the top element of the stack, and it can give
you a new stack where the top element is removed, but it cannot
give you the top element and then modify the stack as a side effect.
Whenever we want to modify a data structure, what we have to do in
a functional language, is to create a new structure instead. And we
need to return this new structure to the caller. Instead of wrapping
query answers and new (or “modified”) data structures in lists so we
can return multiple values, it is much easier to keep the two
operations separate.

Another rule of thumb for interfaces that I will stick to in this book,
with one exception, is that I will always have my functions take the
data structure as the first argument. This isn’t something absolutely
necessary, but it fits the convention for generic functions, so it makes
it easier to work with abstract interfaces, and even when a function is
not abstract—when I need some helper functions—remembering that
the first argument is always the data structure is easier. The one
exception to this rule is the construction of linked lists, where
tradition is to have a construction function, cons, that takes an
element as its first argument and a list as its second argument and
construct a new list where the element is put at the head of the list.
This construction is too much of a tradition for me to mess with, and
I won’t write a generic function of it, so it doesn’t come into conflict
with how we handle polymorphism.

Other than that, there isn’t much more language mechanics to


creating abstract data structures. All operations we define on an
abstract data structure have some intended semantics to them, but
we cannot enforce this through the language; we just have to make
sure that the operations we implement actually do what they are
supposed to do.

8
Chapter 2 abstraCt Data struCtures

Implementing Concrete Data Structures in R

When it comes to concrete implementations of data structures, there


are a few techniques we need in order to translate the data structure
designs into R code. In particular, we need to be able to represent
what are essentially pointers, and we need to be able to represent
empty data structures. Different programming languages will have
different approaches to these two issues. Some allow the definition of
recursive data types that naturally handle empty data structures and
pointers, others have unique values that always represent “empty,”
and some have static type systems to help. We are programming in
R, though, so we have to make it work here.

For efficient data structures in functional programming, we need


recursive data types, which essentially boils down to representing
pointers.

R doesn’t have pointers, so we need a workaround. That workaround


is using lists to define data structures and using named elements in
lists as our pointers.

Consider one of the simplest data structures known to man: the


linked list. If you are not familiar with linked lists, you can read about
them in the next chapter, where I consider them in some detail. In
short, linked lists consist of a head—an element we store in the list—
and a tail—another list, one item shorter. It is a recursive definition
that we can write like this: LIST = EMPTY | CONS(HEAD, LIST)

Here EMPTY is a special symbol representing the empty list, and


CONS—a traditional name for this, from the Lisp programming
language—a symbol that constructs a list from a HEAD element and a
tail that is another LIST. The definition is recursive—it defines LIST in
terms of a tail that is also a LIST—and this in principle allows lists to
be infinitely long. In practice, a list will eventually end up at EMPTY.
9

Chapter 2 abstraCt Data struCtures

We can construct linked lists in R using R’s built-in list data structure.

That structure is not a linked list; it is a fixed-size collection of


elements that are possibly named. We exploit named elements to
build pointers. We can implement the CONS construction like this:

linked_list_cons <- function(head, tail) {

structure(list(head = head, tail = tail),

class = "linked_list_set")

We just construct a list with two elements, head and tail. These will
be references to other objects—head to the element we store in the
list, and tail to the rest of the list—so we are in effect using them as
pointers. We then add a class to the list to make linked lists work as
an implementation of an abstract data structure.

Using classes and generic functions to implement polymorphic


abstract data structures leads us to the second issue we need to deal
with in R. We need to be able to represent empty lists. The natural
choice for an empty list would be NULL, which represents “nothing”
for the built-in list objects, but we can’t get polymorphism to work
with NULL. We can’t give NULL a class. We could, of course, still work
with NULL as the empty list and just have classes for non-empty lists,
but this clashes with our desire to have the empty data structures
being the one point where we decide concrete data structures instead
of just accessing them through an abstract interface. If we didn’t give
empty data structures a type, we would need to use concrete update
functions instead. That could make switching between different
implementations cumbersome. We really do want to have empty data
structures with classes.

The trick is to use a sentinel object to represent empty structures.

Sentinel objects have the same structure as non-empty data structure


objects—which has the added benefit of making some
implementations easier to write—but they are recognized as
representing “empty.” We construct a sentinel as we would any other
object, but we remember it 10

Chapter 2 abstraCt Data struCtures

for future reference. When we create an empty data structure, we


always return the same sentinel object, and we have a function for
checking emptiness that examines whether its input is identical to the
sentinel object. For linked lists, this sentinel trick would look like this:
linked_list_nil <- linked_list_cons(NA, NULL)

empty_linked_list_set <- function() linked_list_nil


is_empty.linked_list_set <- function(x)

identical(x, linked_list_nil)

The is_empty function is a generic function that we will use for all
data structures.

The identical test isn’t perfect. It will consider any list element
containing NA as the last item in a list as the sentinel. Because we
don’t expect anyone to store NA in a linked list—it makes sense to
have missing data in a lot of analysis, but rarely does it make sense
to store it in data structures—it will have to do.

Using a sentinel for empty data structures can also occasionally be


useful for more than dispatching on generic functions. Sometimes,
we actually want to use sentinels as proper objects, because it
simplifies certain functions. In those cases, we can end up with
associating meta- data with

“empty” sentinel objects. We will see examples of this when we


implement red-black search trees. If we do this, then checking for
emptiness using identical will not work. If we modify a sentinel to
change meta-information, it will no longer be identical to the
reference empty object. In those cases, we will use other approaches
to testing for emptiness.

Asymptotic Running Time

Although the operations we define in the interface of an abstract data


type determine how we can use these in our programs, the efficiency
of our programs depends on how efficient the data structure
operations are.

11

Chapter 2 abstraCt Data struCtures

Because of this, we often consider the time efficiency part of the


interface of a data structure—if not part of the abstract data
structure, we very much care about it when we have to pick concrete
implementations of data structures for our algorithms.

When it comes to algorithmic performance, the end goal is always to


reduce wall time—the actual time we have to wait for a program to
finish.

But this depends on many factors that cannot necessarily know about
when we design our algorithms. The computer the code will run on
might not be available to us when we develop our software, and both
its memory and CPU capabilities are likely to affect the running time
significantly. The running time is also likely to depend intimately on
the data we will run the algorithm on. If we want to know exactly
how long it will take to analyze a particular set of data, we have to
run the algorithm on this data. Once we have done this, we know
exactly how long it took to analyze the data, but by then it is too late
to explore different solutions to do the analysis faster.

Because we cannot practically evaluate the efficiency of our


algorithms and data structures by measuring the running time on the
actual data we want to analyze, we use different techniques to judge
the quality of various possible solutions to our problems.

One such technique is the use of asymptotic complexity, also known


as big-O notation. Simply put, we abstract away some details of the
running time of different algorithms or data structure operations and
classify their runtime complexity according to upper bounds known
up to a constant.

First, we reduce our data to its size. We might have a set with n
elements, or a string of length n. Although our data structures and
algorithms might use very different actual wall time to work on
different data of the same size, we care only about the number n and
not the details of the data. Of course, data of the same size is not all
equal, so when we reduce all our information about it to a single size,
we have to be a little careful about what we mean when we talk
about the algorithmic complexity of a problem. Here, we usually use
one of two approaches: we speak of the worst-case or the
average/expected complexity. The worst-case 12

Chapter 2 abstraCt Data struCtures

runtime complexity of an algorithm is the longest running time we


can expect from it on any data of size n. The expected runtime
complexity of an algorithm is the mean running time for data of size
n, assuming some distribution over the possible data.

Second, we do not consider the actual running time for data of size n
—where we would need to know exactly how many operations of
different kinds would be executed by an algorithm, and how long
each kind of operation takes to execute. We just count the number of
operations and consider them equal. This gives us some function of n
that tells us how many operations an algorithm or operation will
execute, but not how long each operation takes. We don’t care about
the details when comparing most algorithms because we only care
about asymptotic behavior when doing most of our algorithmic
analysis.

By asymptotic behavior, I mean the behavior of functions when the


input numbers grow large. A function f ( n) is an asymptotic upper
bound for another function g( n) if there exists some number N such
that g( n) ≤ f ( n) whenever n > N. We write this in big-O notation as
g( n) ∈ O( f( n)) or g( n) = O( f ( n)) (the choice of notation is a little
arbitrary and depends on which textbook or reference you use).

The rationale behind using asymptotic complexity is that we can use


it to reason about how algorithms will perform when we give them
larger data sets. If we need to process data with millions of data
points, we might be about to get a feeling for their running time
through experiments with tens or hundreds of data points, and we
might conclude that one algorithm outperforms another in this range.
But that does not necessarily reflect how the two algorithms will
compare for much larger data. If one algorithm is asymptotically
faster than another, it will eventually outperform the other—we just
have to get to the point where n gets large enough.

A third abstraction we often use is to not be too concerned with


getting the exact number of operations as a function of n correct. We
just want an upper bound. The big-O notation allows us to say that
an algorithm 13

Chapter 2 abstraCt Data struCtures

runs in any big-O complexity that is an upper bound for the actual
runtime complexity. We want to get this upper bound as exact as we
can, to properly evaluate different choices of algorithms, but if we
have upper and lower bounds for various algorithms, we can still
compare them.
Random documents with unrelated
content Scribd suggests to you:
SECTION X
(TRUNK ROUTE)

GLOUCESTER TO OXFORD, 50 MILES

DISTANCES ALONG THE ROUTE

Miles.
Gloucester to Cheltenham 8¾
Cheltenham to Andoversford 6
Andoversford to Northleach 7
Northleach to Burford 9
Burford to Witney 7½
Witney to Eynsham 5¾
Eynsham to Oxford 6

NOTES FOR DRIVERS


Gloucester to Cheltenham.—Level; excellent surface.
There are no hills of any importance all the way to Oxford, but the
surface is rather rough between Andoversford and Burford.
The road falls nearly all the way from Northleach to Oxford.

PLACES OF INTEREST ON THE ROUTE


Cheltenham.—A watering-place dating from the eighteenth
century. Spa; promenades; St. Mary's Church, Decorated.
Northleach.—Picturesque Cotswold village-town. Perpendicular
church, with famous brasses of wool-merchants and remarkably
fine porch.
Burford.—A very interesting and picturesque old town; several old
houses; market hall; church, large and irregular, Norman, Early
English, and Perpendicular; Priory ruins.
Asthall Barrow.—A prominent prehistoric mound.
Witney.—A pleasant and unusually charming old town, famous for
blankets. Church very picturesque, chiefly Early English; old
market house.
Eynsham.—A quaint old village with old market house, church, and
picturesque houses. Red Lion Inn with quaint sign.

(Trunk) No. 10. GLOUCESTER TO OXFORD.

View larger image


(Trunk) No. 10. GLOUCESTER TO OXFORD.

View larger image


At W o t t o n S t . M a r y, Churchdown Hill is a prominent feature on
the right. Some picturesque old cottages stand beside the road,
while the general aspect of the country is pastoral, broken up by
large orchards, a delightful feature of the county. The road rises
slightly as Cheltenham is approached.

Town Plan No. 11—Cheltenham.

View larger image


CHELTENHAM
Cheltenham stands close to the steep, north-west face of the
Cotswold Hills, and until the springs were discovered in 1716 it was
but a struggling hamlet. It is now an aggregation of imposing
squares, crescents, promenades, and villas, interspersed with
beautiful parks. As may be expected, there are few antiquities to be
found in a town of such mushroom growth, the only exception being
the P a r i s h C h u r c h o f S t . M a r y, standing just off the High
Street. The prevailing style of the building is early Decorated, and it
contains a piscina believed to be one of the largest and most perfect
in England. To those interested in modern architecture the C h u r c h
o f S t . S t e p h e n may be mentioned, but A l l S a i n t s ', the
parish church of Pittville, is the best modern expression of
architectural ideals in Cheltenham, although the R o m a n
C a t h o l i c C h u r c h o f S t . G r e g o r y is a formidable rival. The
public buildings are on a level with the importance of the town. The
merits and uses of the chalybeate and other waters are easily
discovered locally, and no one who remembers the oft-repeated
epitaph of the individual who with three daughters 'died from
drinking the Cheltenham waters' should be prejudiced against their
good properties, which for certain ailments are not to be despised.
Cheltenham is a famous educational centre for girls, and
Gloucestershire, as a whole, has been in the van in educational
matters from quite early times.
Cheltenham is the 'Coltham' in 'John Halifax, Gentleman,' where
John and Phineas saw Mrs. Siddons act.

The road to Oxford from Cheltenham crosses the beautiful


Cotswolds, climbing up to 800 feet at the Puesdown Inn. From this
point there are wide expanses visible in nearly every direction; but
such views do not give one the real charm of the Cotswolds. To
become intimate with the exquisite valleys and secluded upland
villages, one must be in a mood to potter and loiter, and be content
to desert the car at intervals in order to plunge into some beautiful
beech-wood, falling steeply down a declivity, and revealing glimpses
between the tall smooth trunks of the Vale of Severn, or some
sleepy hollow wherein a silver-grey village nestles. The beautiful
architecture of the Cotswolds, in conjunction with its lovely scenery,
is a joy to all who know these oolite hills. Cottages, farms, mills, and
manor-houses, all with steep roofs of grey stone like the walls,
stately gables, mullioned windows, and picturesque chimneys, are all
one can desire.
Even if there is no time to wander from the direct road, one cannot
avoid seeing an exceedingly pleasing little Cotswold town. This is

NORTHLEACH,
a place of some importance when the woollen industry of these hills
was flourishing. There is a subtle charm in the greyness of the old
houses, relieved by the dark green of yew and the lighter tones of
deciduous trees and grass banks here and there. The quaint little
shops add other touches of colour, and wherever one turns there are
pictures of simple Cotswold life, not much altered by the rapid
changes of recent years. The old fellow standing meditatively by the
churchyard gate may talk of the great changes since his youth, when
the cloth industry had not ebbed away from the hills, but to outward
appearances Northleach is, one suspects, little altered since the days
of our great-grandparents, if, indeed, anything has materially
changed the town since the beautiful Perpendicular church was put
up. The date of its building was about the year 1489, when Cotswold
wool was one of the chief industries of England. One may admire
the embattled spire and the graceful delicacy of the whole building,
but it is by its porch that one remembers Northleach Church. It is
illustrated here; but, good as the drawing is, it does not do justice to
the wonderful beauty of that noble piece of Perpendicular
craftsmanship surmounted by its parvise.
On the floor of the nave are a series of brasses to the memory of
some of the most successful of the wool-merchants of the town.
They belong to the fifteenth century, and are exceptionally fine
examples of brasses of the period, giving the details of costume with
the greatest faithfulness. It is pleasant to find that the wealthy men
of the Cotswold wool industry seem to have devoted their surplus
riches to such public works as schools, almshouses, and churches.
At Northleach the Roman Foss Way is crossed coming from
Cirencester in a north-easterly direction.
A few miles beyond Northleach, S h e r b o r n e P a r k, the residence
of Lord Sherborne, is passed on the left. It is a dignified house,
situated in open country, many portions of which are well wooded.
From this point all the way to Witney the road falls steadily, with the
shallow, but always pleasing, valley of the Windrush just below on
the left. This pretty stream coming out of the heart of the Cotswolds
is one of the chief feeders of the Thames, which it meets a dozen
miles above Oxford. Actually on the road there are no villages except
Little Minster between Northleach and Witney, but just below the
highway, on the banks of the little river, there are several. The first
three—Windrush and Great and Little Barrington—are in
Gloucestershire, and the rest are in Oxfordshire. It is tempting to
describe all these places, but one must be content with pointing out
the particular charm of

BURFORD,
one of the most delightful of the old-world towns of the county.
There is a town hall, probably of the fifteenth century, and adjoining
it are some of the best of the old houses in the town. Close to the
stream stands the splendid cruciform church, with its tower and west
door dating back to the Norman period. In Early English times nearly
the whole building appears to have been changed into the Gothic
style, and another transformation took place in the fifteenth century,
when the Perpendicular phase had set in. Owing to the Sylvester
aisle and several chapels, the church is of curious shape, and this
helps to give that indescribable atmosphere of pre-Reformation days
entirely vanished from so many old churches in this country.
Both the school and the almshouses are old foundations, and the
Priory, now a partial ruin, although preserving no ecclesiastical
remains, is a picturesque Elizabethan building to some extent rebuilt
in 1808.
A mile or two beyond Burford one passes Asthall Barrow on the
right-hand side of the road, and only a few yards away across a
field. It is a prehistoric mound of earth, now kept in position by a
circular retaining wall of stone, thus preventing degradation. The
trees surmounting it form a prominent landmark. About three miles
farther on is the fine old manor-house of M i n s t e r L o v e l l, about
a mile to the left, on the Windrush.

WITNEY
Soon after turning to the right the road enters the main street of
picturesque old Witney at right angles. Extending away some
distance to the right is the pleasant elongated belt of green, giving
much charm and distinction to the place, and at the end of the
grassy perspective, rising in stately dignity from old trees, appears
the tower and spire of the cruciform church. This is one of those
peculiarly fascinating buildings one finds it hard to leave. It is mainly
an Early English church, but there are features of other periods, and
among them a Decorated window on the north side, which is the
finest in the whole county. The spire is an Early English masterpiece.
In the middle of the little town stands the quaint Butter Cross, dated
1683. On the west side of the green is the Grammar School (1663),
with an avenue of elms.
The blanket industry is still in existence, for in spite of modern
competition the little place holds its own on account of some
particular benefit the wool derives from the water of the
neighbourhood.
EYNSHAM
is the last village passed on the way to Oxford. It is a sleepy and
picturesque little place with a small market hall, the shaft of a
fifteenth-century cross, and an inn-sign of the drollest order. This
sign hangs outside the Red Lion, and the King of Beasts is painted
on one side, but the draughtsman had difficulty in accommodating
the tail, and he solved it by the original plan of painting the caudal
appendage on the opposite face of the sign!
Just below Eynsham the road crosses the Thames at Swinford
Bridge, where the beautiful hanging woods of Wytham Hill are on
the left, and a couple of miles farther on the spires and towers of
Oxford are in sight.
THE CHURCH PORCH AT NORTHLEACH.
A rare example of the stateliness of
Perpendicular architecture in a village
church.
LOOP No. 8

OXFORD TO STRATFORD-ON-AVON,
COVENTRY, BANBURY, AND OXFORD, 110
MILES

DISTANCES ALONG THE ROUTE

Miles.
Oxford to Woodstock 8
Woodstock to Enstone 6¾
Enstone to Long Compton 8
Long Compton to Shipstone-on-Stour 5¾
Shipstone-on-Stour to Stratford-on-Avon 10 ½
Stratford-on-Avon to Leamington 10 ½
Leamington to Warwick 2¼
Warwick to Kenilworth 4¾
Kenilworth to Coventry 5¾
Coventry to Princethorpe 7
Princethorpe to Southam 6
Southam to Fenny Compton 5½
Fenny Compton to Banbury 8¼
Banbury to Deddington 6
Deddington to Sturdy's Castle Inn 7¾
Sturdy's Castle Inn to Kidlington 2
Kidlington to Oxford, Carfax 5¼

NOTES FOR DRIVERS


Oxford to Stratford.—Splendid surface; steep drop down to Long
Compton.
Stratford to Coventry.—Surface on the whole excellent; not so
good near Stratford.
Coventry to Banbury.—An excellent road, but a few rather steep
hills are encountered.
Banbury to Oxford.—Excellent.

PLACES OF INTEREST ON THE ROUTE


Woodstock.—A little town, with a church containing several styles
of architecture; Blenheim, the residence of the Dukes of
Marlborough; the Column of Victory.
Long Compton.—The Rollright Stones, a prehistoric circle of
importance.
Stratford-on-Avon.—Shakespeare's birthplace; the memorial; the
church and its interesting monuments; New Place, the residence
of the poet; the Grammar School; Guild Chapel; and Anne
Hathaway's Cottage, 1 mile west.
Warwick.—A picturesque town, famous for its castle; St. Mary's
Church and the Beauchamp Chapel and monuments; Lord
Leycester's Hospital; the West Gate and various old houses.
Leamington.—A beautiful spa; the Jephson Gardens.
Guy's Cliffe.—An exquisitely-situated country house.
Kenilworth.—A little town, containing half-timbered houses; the
ruins of the famous castle; the church, chiefly Decorated; the
remains of the Priory.
Coventry.—A fairly large town; St. Michael's, an exceedingly fine
parish church; Holy Trinity Church; St. Mary's Hall, a fourteenth-
century guild-hall; St. John's Church; the Bablake Hospital;
Peeping Tom; Ford's Hospital.
Long Itchington.—Interesting fourteenth-century church.
Southam.—A town without much interest.
Banbury.—A little Oxfordshire town, famed for its cross and its
cakes; but the cross is modern, and so is the church.
View larger image.
View larger image.
Loop 8. OXFORD TO COVENTRY.

There are two main roads running to Woodstock from Oxford, lying
parallel to each other; the western one should be selected. It passes
through a well-wooded country, part of the valleys of the Thames
and Evenlode rivers. Upon reaching Woodstock, B l e n h e i m
P a l a c e claims attention, with the entrance to the park lying upon
the left. The house was built at the public expense in 1715 as a
national recognition of the services of the Duke of Marlborough. It
was designed by Vanbrugh, and is of a heavy Renaissance character.
The interior decorations and the treasures preserved in it are of an
exceedingly interesting nature. (It is open to the public every day,
except Saturdays and Sundays, between 11 and 1, and the gardens
from 11 to 2. Tickets 1s. each.) The park contains the site of the old
Manor-house of Woodstock, which is supposed to have stood upon
the foundations of a Roman villa; it was a royal residence of the
Saxon kings. Here Alfred the Great translated Boethius, and King
Ethelred published his code of laws. Woodstock was the scene of the
courtship of Henry II. and Rosamund Clifford, whose birthplace was
Clifford Castle (see p. 175). Queen Elizabeth was a prisoner for a
time in the old manor-house, and it endured a siege from the
Parliamentarians, finally disappearing in 1723.

WOODSTOCK
This little town sprang into existence solely in consequence of the
proximity of the royal seat. T h e C h u r c h o f S t . M a r y
M a g d a l e n e is of Norman date, but much restoration has taken
place. The south aisle is Early English, and contains part of a
Norman doorway. The chancel and north aisle are Decorated, while
the west porch and west tower are Perpendicular. There are many
monuments of interest in the church.
Soon after leaving Woodstock the Column of Victory is prominent on
the left, where the ancient course of the Akeman Street, coming
from Cirencester, is crossed, and shortly afterwards Grim's Dyke
occurs, one of the many Grim's Dykes that are found in England.
Near E n s t o n e is a cromlech, called the 'Hoarstone,' and soon
afterwards a turning to the left leads to

CHIPPING NORTON
This is a quiet little town, devoted to the manufacture of woollen
goods, and especially horse-cloths. The 'Chipping' is derived from
the same root as 'Chepe,' a market. In the church the chief objects
of interest are some fourteenth-century brasses, which, however,
suffered very much in a restoration some forty years since, when
they were wrenched from their matrices and thrown into the parvise.
Of the castle which once stood here nothing remains.
Between Chipping Norton and Long Compton, at Great Rollright, are
the well-known R o l l r i g h t S t o n e s, consisting of a prehistoric
circle of standing stones and a cromlech. They are sixty in number,
and lie about 500 yards to the left of the main road. After passing
the stiff descent into Long Compton, a good surface is found to
Shipstone-on-Stour, although the road is second class; but beyond
that town a first-class road lies up the valley of the Stour to
Stratford-on-Avon. At Alderminster tram-lines commence, which
reach to Stratford, and a short distance beyond, Atherstone-on-Stour
is passed, where formerly stood a monastery of mendicant friars.
The scenery, meanwhile, has been gradually assuming the
characteristics which distinguish the beautiful county of Warwick—
luxurious hedgerows, gently-flowing streams, red loam in the fields
contrasting with the varying shades of green. The half-timbered
houses and cottages introduce another pleasant feature into the
landscape.

STRATFORD-ON-AVON
This far-famed country town on the banks of the Avon presents a
general appearance of prosperity, the well-built houses, wide streets,
and prevailing aspect of cleanliness giving this impression.
Everything in the town, however, lapses into insignificance in face of
the paramount interest attaching to the town as the birthplace of
Shakespeare. Whether the 'Bard of Avon' was nothing more than an
Elizabethan play-actor or the author of the plays now so widely
attributed to the great scholar and statesman, Francis Bacon, is a
question which now cools the spirit of devotion of many a pilgrim;
but however keen a Baconian may be the visitor to Stratford, he
cannot fail to appreciate the charm of the carefully-restored
Elizabethan houses associated with Shakespeare.
S h a k e s p e a r e ' s B i r t h p l a c e is in Henley Street, a half-
timbered, unpretentious house of two rooms and a kitchen on the
ground-floor, with the room overhead in which he was born. The
adjoining cottage has been converted into a museum, in which
documents and relics bearing in a direct or remote manner with the
poet—and some, it must be confessed, are very remote—are
preserved. The birthplace was in possession of the members of the
family for two centuries after the death of Shakespeare in 1616; in
1847 it was purchased by subscription for £3,000 and carefully
restored. (Admission 1s.—6d. for the birthroom and 6d. for the
museum.)
T h e To w n H a l l is in the High Street; on the front is a statue of
Shakespeare, presented by Garrick.
N e w P l a c e stood close by, but of the house occupied by the poet
during the last nineteen years of his life there is nothing left but the
site. In it lived Dr. Hall, who married Shakespeare's daughter
Susannah. The house was pulled down in 1702 by Sir John Clopton,
and the new building on its site, together with the famous mulberry-
tree, were destroyed by the Rev. Francis Gastrell in 1759, 'because
he was pestered by visitors'! In 1861 the site of New Place and its
gardens were purchased by public subscription. A Shakespeare
Library and Museum have been established there, open daily except
Saturday and Sunday; admission 6d. On Saturday the Gardens are
free.
STRATFORD-ON-AVON.
Holy Trinity Church contains the tomb of
Shakespeare.

At the opposite corner, Chapel Lane, stands the G r a m m a r


S c h o o l, founded in 1553, where the poet is reputed to have been
educated. It is a delightful old timber-framed house standing near
the Guild Chapel, a Perpendicular building which is conspicuous in
the High Street.
T h e S h a k e s p e a r e M e m o r i a l T h e a t r e occupies a
pleasant position on the banks of the Avon. The old theatre was
demolished in 1872, and the present building erected at a cost of
£30,000.
T h e P a r i s h C h u r c h, of Early English and Perpendicular
architecture, is a fine cruciform building standing on the site of an
early Saxon monastery. In Edward III.'s reign John de Stratford
rebuilt the south aisle and erected a chantry for priests. In 1351
Ralph de Stratford built a chapel for the latter, now known as the
College. The beautiful choir dates from the time of Dean Balshall
(1465). Shakespeare's monument is on the left side of the chancel;
the door there formerly led to the charnel-house, and the grave is
near the monument under a flat stone, upon which is the oft-quoted
verse said to have been written by Shakespeare. Between this spot
and the north wall is buried his widow, who died in 1623, while
those of relatives lie near, such as Susannah, the eldest daughter,
and her husband, Dr. Hall, and Thomas Nashe, who married
Shakespeare's only granddaughter. (Admission to the church 6d.)
A n n e H a t h a w a y ' s C o t t a g e is at Shottery, a mile west of
Stratford, divided since the poet's time into three tenements. The
room where Anne was born is shown.
C h a r l e c o t e P a r k lies about four miles north-east of Stratford. It
is famous for its hall, erected in 1547 by Sir Thomas Lucy upon the
capital E plan, and was visited by Queen Elizabeth. Here also is the
reputed site of Shakespeare's deer-shooting escapades.
The main road to Warwick lies through a beautifully-wooded country,
rich in pleasant views of hill and dale. Clopton Tower is on the left
shortly after leaving.
The tower of Barford Church can be seen two miles off to the right
of the main road; it was rebuilt in the last century, except the tower,
which retains the marks of Cromwellian cannon-balls.
S h e r b o u r n e is near at hand. The church is modern, and of fine
design.
Town Plan No. 13—Warwick.

View larger image

WARWICK
It has been asserted that the history of Warwick is the history of
England, and certain it is that the ancient town has been involved in
the majority of the great events which have helped to make the
national record. In those stirring events W a r w i c k C a s t l e has
played no mean part, and is still the glory of the town and county. It
is undoubtedly the most magnificent of the ancient feudal mansions
still used as a residence, and its grand position upon a crag
overlooking the Avon has accentuated its imposing grandeur in no
mean degree. Its chief features are Cæsar's Tower and Guy's Tower,
of the fourteenth century, and the Gateway Tower in the centre. The
residential apartments and the Great Hall suffered in the fire of
1871, but have been rebuilt. Both the castle and the contents teem
with interest. (Open to visitors as a rule; no fixed fee. Tickets
obtained at small cottage opposite Castle Lodge, Castle Hill.)
S t . M a r y ' s C h u r c h is one of the most interesting ecclesiastical
buildings in the country. A Saxon church stood upon the site, and a
later building was made collegiate by Earl Roger de Newburgh. It
was granted to the town as a parish church at the Dissolution. The
central object of interest is the famous Beauchamp Chapel, 1443 to
1464, one of the best examples extant of Perpendicular architecture
bordering upon the Tudor, and showing occasionally traces of
incipient Renaissance. Richard Beauchamp, Earl of Warwick, Regent
of France, and guardian of Edward VI., lies buried here, and his
effigy in bronze, the finest in existence of that nature, lies in the
centre of the chapel. Against the north wall is the magnificent
monument of the famous Robert Dudley, Earl of Leicester—splendid
in life and sumptuous in death. Two small ante-chapels are seen—
one is probably a chantry. In the chancel lie Thomas Beauchamp,
Earl of Warwick, and his second Countess, both of whom died in
1370; their effigies of white marble, with many 'weepers' round the
pedestal, are of great interest.
L o r d L e y c e s t e r ' s H o s p i t a l .—There are but few places in
England where such a picturesque and impressive grouping of old
timbered houses may be seen; antique gables and eaves, richly-
carved beams and mysterious recesses; overhanging stories and
twisted chimneys, with an old gateway and a church tower thrown in
—it forms a gem of which any city might be proud. The Hospital was
originally a hall of the Guilds; in 1571 the Earl founded it for the
reception of twelve poor men, who still wear the bear and ragged
staff as a cognizance. Many half-timbered houses and quaint old-
world nooks remain in Warwick to delight the eye of the artist and
the antiquary, especially near the castle.
Town Plan No. 14—Leamington.

View larger image

LEAMINGTON
A little over a mile separates Warwick from the Royal Leamington
Spa, a beautiful garden city, which has sprung into existence by
reason of the discovery of the efficacy possessed by the mineral
waters in 1784. Until that period it was a small village called
Leamington Priors. The chief springs are saline and sulphuretted
saline.
The J e p h s o n G a r d e n s are beautifully placed on the north bank
of the River Leam, and form one of the chief centres of attraction,
and the Royal Pump Room Gardens face the river on the other side
of the bridge. As might be expected from such a modern town, there
are no objects of antiquity to describe. Returning to Warwick, the
road to Guy's Cliff is taken, running due north, and the entrance-
lodge occurs in about a mile. A fine view of the house is obtained
from this point on looking up the avenue of majestic firs; it was built
in 1822, succeeding a small country mansion, and is in the
possession of Lord Algernon Percy. Situated upon a cliff with a wide
part of the river beneath, it forms a singularly beautiful picture. (It is
only shown to visitors when the family is absent.)
T h e C h a p e l adjoins the mansion on the east, and contains a
figure of Guy, Earl of Warwick, dating from the fourteenth century.
Guy's Lane is near the chapel.
T h e M i l l was built in 1821, and occupies the site of one dating as
far back as Saxon times.
Guy of Warwick is a mythical personage, and the romance
mentioning his deeds dates from the thirteenth century. In the
fifteenth century, when the age of chivalry and romance was at its
zenith, Guy was treated in the same manner as King Arthur, and all
kinds of doughty deeds were attributed to him by the romancers.
B l a c k l o w H i l l stands half a mile farther on to the left of the
road. It is surmounted by a cross, erected in 1821 to commemorate
the execution in 1312 of Piers Gaveston. At Gloucester, the tomb of
Edward II., who, like his favourite, came to a tragic end, has been
mentioned.

KENILWORTH
T h e C a s t l e is the centre of attraction, although there are some
good examples of half-timbered cottages to be seen in the long
street of the little town. The fortress was in ancient times one of the
strongest in England, as it afforded accommodation for a large
garrison, and by reason of the lake and broad moats filled with
water—now disappeared—it was almost impregnable. Numerous
roads converged towards it as the centre of England, and for many
years it was a royal residence. T h e K e e p was built about 1170,
and is a splendid example of military architecture of the late Norman
period. It is square, with a projecting rectangle, and turrets at the
corners. The walls at the base are 14 feet thick. T h e G a r d e n,
celebrated in Scott's novel, lay upon the north side of the keep.
South of the keep occur Leicester's Buildings, with fourteenth-
century kitchens and other offices between. By the side of the Great
Hall was the Strong Tower, called Mervyn's Tower by Scott.
Mortimer's Tower is isolated to the south-east; the cutting through
the great dam which restrained the waters of the lake occurred here.
The tilt-yard lay upon the top of the dam. Beyond the Great Lake
was the C h a s e, and the circuit of the castle, manor, parks and
other lands, was about twenty miles. Many historical names are
associated with Kenilworth—the Clintons, Simon de Montfort, John of
Gaunt, and Robert Dudley, who entertained Queen Elizabeth for
seventeen days, and spent a fortune in doing so. The castle was
dismantled and the lake drained in the time of the Commonwealth.
FORD'S HOSPITAL, COVENTRY.
A late fifteenth century almshouse
enriched with much elaborate carving.

T h e C h u r c h lies east of the castle. The tower and nave are of


Decorated work, but a Norman doorway has been inserted in the
west side of the tower, taken, probably, from the Priory.
T h e P r i o r y stood close to the church; it was founded about 1122
by Geoffrey de Clinton, and richly endowed. The remains of a
gatehouse may be seen, and also some exposed foundations of the
walls of the church.
On leaving Kenilworth for Coventry a stretch of moorland extends
upon the right hand, on which are two mounds with the usual fosses
around the summits, denoting British hill-forts. Beyond this the road
begins to assume that characteristic which has made the way from
Kenilworth to Coventry renowned as 'one of the two finest roads in
England'—needless to say, the other road is from Coventry to
Kenilworth—a magnificent avenue with broad strips of greensward
lying on either side, and glimpses of splendid Warwickshire scenery
between the boles, justify the foregoing descriptions.
Two miles from Kenilworth is Gibbet Hill, the erection upon which
has now gone, but was used last in 1765 for the execution of two
murderers. Crossing Stivichall Common, with its triple array of oak-
trees on either side the road, the Coventry Grammar School
buildings are passed upon the left, and the 'City of the Three Spires'
is entered.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

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

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like