You are on page 1of 53

Handbook of Data Structures and

Applications Dinesh P. Mehta


Visit to download the full and correct content document:
https://textbookfull.com/product/handbook-of-data-structures-and-applications-dinesh-
p-mehta/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Probabilistic data structures and algorithms for big


data applications Gakhov

https://textbookfull.com/product/probabilistic-data-structures-
and-algorithms-for-big-data-applications-gakhov/

Advanced Data Structures Theory and Applications 1st


Edition Suman Saha

https://textbookfull.com/product/advanced-data-structures-theory-
and-applications-1st-edition-suman-saha/

Advances in Big Data and Cloud Computing Proceedings of


ICBDCC18 J. Dinesh Peter

https://textbookfull.com/product/advances-in-big-data-and-cloud-
computing-proceedings-of-icbdcc18-j-dinesh-peter/

Learning functional data structures and algorithms


learn functional data structures and algorithms for
your applications and bring their benefits to your work
now Khot
https://textbookfull.com/product/learning-functional-data-
structures-and-algorithms-learn-functional-data-structures-and-
algorithms-for-your-applications-and-bring-their-benefits-to-
Big Data Analytics with Java 1st Edition Rajat Mehta

https://textbookfull.com/product/big-data-analytics-with-
java-1st-edition-rajat-mehta/

Handbook of Statistical Analysis and Data Mining


Applications 2nd Edition Robert Nisbet

https://textbookfull.com/product/handbook-of-statistical-
analysis-and-data-mining-applications-2nd-edition-robert-nisbet/

Cloud Native Data Center Networking 1st Edition Dinesh


G. Dutt

https://textbookfull.com/product/cloud-native-data-center-
networking-1st-edition-dinesh-g-dutt/

Cloud Native Data Center Networking Architecture


Protocols and Tools Dinesh G. Dutt

https://textbookfull.com/product/cloud-native-data-center-
networking-architecture-protocols-and-tools-dinesh-g-dutt/

Learning Functional Data Structures and Algorithms


Learn functional data structures and algorithms for
your applications and bring their benefits to your work
now 1st Edition Atul S. Khot
https://textbookfull.com/product/learning-functional-data-
structures-and-algorithms-learn-functional-data-structures-and-
algorithms-for-your-applications-and-bring-their-benefits-to-
Handbook of
Data Structures
and Applications
Second Edition
Handbook of
Data Structures
and Applications
Second Edition

Edited by
Dinesh P. Mehta
Sartaj Sahni
MATLAB R
is a trademark of The MathWorks, Inc. and is used with permission. The MathWorks does not warrant the accuracy of the text or
exercises in this book. This book’s use or discussion of MATLABR
software or related products does not constitute endorsement or sponsorship
by The MathWorks of a particular pedagogical approach or particular use of the MATLAB R
software.

CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742


c 2018 by Taylor & Francis Group, LLC
CRC Press is an imprint of Taylor & Francis Group, an Informa business

No claim to original U.S. Government works

Printed on acid-free paper

International Standard Book Number-13: 978-1-4987-0185-3 (Hardback)

This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to publish reliable data
and information, but the author and publisher cannot assume responsibility for the validity of all materials or the consequences of their use. The
authors and publishers have attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright
holders if permission to publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let us
know so we may rectify in any future reprint.

Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in any form by
any electronic, mechanical, or other means, now known or hereafter invented, including photocopying, microfilming, and recording, or in any
information storage or retrieval system, without written permission from the publishers.

For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://www.copyright.com/) or
contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organi-
zation that provides licenses and registration for a variety of users. For organizations that have been granted a photocopy license by the CCC, a
separate system of payment has been arranged.

Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for identification and explanation
without intent to infringe.

Library of Congress Cataloging-in-Publication Data

Names: Mehta, Dinesh P., editor. | Sahni, Sartaj, editor.


Title: Handbook of data structures and applications / edited by Dinesh P. Mehta and Sartaj Sahni.
Other titles: Data structures and applications
Description: Second edition. | Boca Raton, Florida : CRC Press, [2018] | Includes bibliographical references and index.
Identifiers: LCCN 2017041375| ISBN 9781498701853 (hardback) | ISBN 9781315119335 (e-book)
Subjects: LCSH: System design--Handbooks, manuals, etc. | Data structures (Computer science)--Handbooks, manuals, etc.
Classification: LCC QA76.9.S88 H363 2005 | DDC 005.7/3--dc23 LC record available at https://lccn.loc.gov/2017041375

Visit the Taylor & Francis Web site at


http://www.taylorandfrancis.com

and the CRC Press Web site at


http://www.crcpress.com
To our wives,
Usha Mehta and Neeta Sahni
Contents

Preface to the Second Edition .....................................................................................................................................xi


Preface to the First Edition........................................................................................................................................xiii
Editors .......................................................................................................................................................................... xv
Contributors ..............................................................................................................................................................xvii

PART I Fundamentals
1 Analysis of Algorithms ....................................................................................................................................... 3
Sartaj Sahni
2 Basic Structures ................................................................................................................................................. 23
Dinesh P. Mehta
3 Trees ................................................................................................................................................................... 35
Dinesh P. Mehta
4 Graphs ................................................................................................................................................................ 49
Narsingh Deo

PART II Priority Queues


5 Leftist Trees........................................................................................................................................................ 69
Sartaj Sahni
6 Skew Heaps ........................................................................................................................................................ 77
C. Pandu Rangan
7 Binomial, Fibonacci, and Pairing Heaps......................................................................................................... 85
Michael L. Fredman
8 Double-Ended Priority Queues ....................................................................................................................... 97
Sartaj Sahni

PART III Dictionary Structures


9 Hash Tables ......................................................................................................................................................117
Pat Morin
10 Bloom Filter and Its Variants .........................................................................................................................131
Shigang Chen
11 Balanced Binary Search Trees ........................................................................................................................151
Arne Andersson, Rolf Fagerberg, and Kim S. Larsen
12 Finger Search Trees .........................................................................................................................................171
Gerth Stølting Brodal

vii
viii Contents

13 Splay trees ........................................................................................................................................................179


Sanjeev Saxena
14 Randomized Dictionary Structures...............................................................................................................197
C. Pandu Rangan
15 Trees with Min Weighted Path Length..........................................................................................................215
Wojciech Rytter
16 B Trees ..............................................................................................................................................................233
Donghui Zhang

PART IV Multidimensional/Spatial Structures


17 Multidimensional Spatial Data Structures....................................................................................................251
Hanan Samet
18 Planar Straight Line Graphs ...........................................................................................................................277
Siu-Wing Cheng
19 Interval, Segment, Range, Priority Search Trees ..........................................................................................291
D. T. Lee and Hung-I Yu
20 Quadtrees and Octtrees ..................................................................................................................................309
Srinivas Aluru
21 BSP Trees..........................................................................................................................................................329
Bruce F. Naylor
22 R-Trees .............................................................................................................................................................343
Scott Leutenegger and Mario A. Lopez
23 Managing Spatio-Temporal Data ..................................................................................................................359
Sumeet Dua and S. S. Iyengar
24 Kinetic Data Structures ..................................................................................................................................377
Leonidas Guibas
25 Online Dictionary Structures.........................................................................................................................389
Teofilo F. Gonzalez
26 Cuttings............................................................................................................................................................397
Bernard Chazelle
27 Approximate Geom Query Structures ..........................................................................................................405
Christian A. Duncan and Michael T. Goodrich
28 Geometric and Spatial Data Structures in External Memory .....................................................................419
Jeffrey Scott Vitter

PART V Miscellaneous
29 Tries ..................................................................................................................................................................445
Sartaj Sahni
30 Suffix Trees and Suffix Arrays ........................................................................................................................461
Srinivas Aluru
31 String Searching ..............................................................................................................................................477
Andrzej Ehrenfeucht and Ross M. McConnell
Contents ix

32 Binary Decision Diagrams .............................................................................................................................495


Shin-ichi Minato
33 Persistent Data Structures ..............................................................................................................................511
Haim Kaplan
34 Data Structures for Sets ..................................................................................................................................529
Rajeev Raman
35 Cache Oblivious Data Structures...................................................................................................................545
Lars Arge, Gerth Stølting Brodal, and Rolf Fagerberg
36 Dynamic Trees.................................................................................................................................................567
Camil Demetrescu, Irene Finocchi, and Giuseppe F. Italiano
37 Dynamic Graphs .............................................................................................................................................581
Camil Demetrescu, Irene Finocchi, and Giuseppe F. Italiano
38 Succinct Representation of Data Structures .................................................................................................595
J. Ian Munro and S. Srinivasa Rao
39 Randomized Graph Data Structures .............................................................................................................611
Surender Baswana and Sandeep Sen
40 Searching and Priority Queues in o(log n) Time .........................................................................................627
Arne Andersson

PART VI Data Structures in Langs and Libraries


41 Functional Data Structures ............................................................................................................................639
Chris Okasaki
42 LEDA, a Platform for Combinatorial and Geometric Computing.............................................................653
Stefan Naeher
43 Data Structures in C++...................................................................................................................................667
Mark Allen Weiss
44 Data Structures in JDSL..................................................................................................................................679
Michael T. Goodrich, Roberto Tamassia, and Luca Vismara
45 Data Structure Visualization ..........................................................................................................................697
John Stasko
46 Drawing Trees..................................................................................................................................................707
Sebastian Leipert
47 Drawing Graphs ..............................................................................................................................................723
Peter Eades and Seok-Hee Hong
48 Concurrent Data Structures...........................................................................................................................741
Mark Moir and Nir Shavit

PART VII Applications


49 IP Router Tables ..............................................................................................................................................765
Sartaj Sahni, Kun Suk Kim, and Haibin Lu
50 Multidimensional Packet Classification........................................................................................................783
Pankaj Gupta
x Contents

51 Data Structures in Web Information Retrieval ............................................................................................799


Monika Henzinger
52 The Web as a Dynamic Graph .......................................................................................................................805
S. N. Maheshwari
53 Layout Data Structures ...................................................................................................................................817
Dinesh P. Mehta
54 Floorplan Rep in VLSI....................................................................................................................................833
Zhou Feng, Bo Yao, and Chung-Kuan Cheng
55 Computer Graphics.........................................................................................................................................857
Dale McMullin and Alyn Rockwood
56 Geographic Information Systems ..................................................................................................................871
Bernhard Seeger and Peter Widmayer
57 Collision Detection .........................................................................................................................................889
Ming C. Lin and Dinesh Manocha
58 Image Data Structures ....................................................................................................................................903
S. S. Iyengar, V. K. Vaishnavi, and S. Gunasekaran
59 Computational Biology ..................................................................................................................................917
Paolo Ferragina, Stefan Kurtz, Stefano Lonardi, and Giovanni Manzini
60 Data Structures for Cheminformatics...........................................................................................................935
Dinesh P. Mehta and John D. Crabtree
61 Elimination Structures in Scientific Computing..........................................................................................945
Alex Pothen and Sivan Toledo
62 Data Structures for Databases........................................................................................................................967
Joachim Hammer and Markus Schneider
63 Data Structures for Big Data Stores...............................................................................................................983
Arun A. Ravindran and Dinesh P. Mehta
64 Data Mining.....................................................................................................................................................997
Vipin Kumar, Pang-Ning Tan, and Michael Steinbach
65 Computational Geometry: Fundamental Structures.................................................................................1013
Mark de Berg and Bettina Speckmann
66 Computational Geometry: Proximity and Location..................................................................................1027
Sunil Arya and David M. Mount
67 Computational Geometry: Generalized (or Colored) Intersection Searching........................................1043
Prosenjit Gupta, Ravi Janardan, Saladi Rahul, and Michiel Smid
Index ........................................................................................................................................................................1059
Preface to the Second Edition

It has been over a decade since the first edition of this handbook was published in 2005. In this edition, we have attempted to
capture advances in data structures while retaining the seven-part structure of the first edition. As one would expect, the discipline
of data structures has matured with advances not as rapidly forthcoming as in the twentieth century. Nevertheless, there have
been areas that have seen significant progress that we have focused on in this edition.
We have added four new chapters on Bloom Filters; Binary Decision Diagrams; Data Structures for Cheminformatics; and
Data Structures for Big Data Stores. In addition, we have updated 13 other chapters from the original edition.

Dinesh P. Mehta
Sartaj Sahni
October 2017

xi
Preface to the First Edition

In the late 1960s, Donald Knuth, winner of the 1974 Turing Award, published his landmark book The Art of Computer Program-
ming: Fundamental Algorithms. This book brought together a body of knowledge that defined the data structures area. The term
data structure, itself, was defined in this book to be A table of data including structural relationships. Niklaus Wirth, the inven-
tor of the Pascal language and winner of the 1984 Turing award, stated that “Algorithms + Data Structures = Programs.” The
importance of algorithms and data structures has been recognized by the community and consequently, every undergraduate
Computer Science curriculum has classes on data structures and algorithms. Both of these related areas have seen tremendous
advances in the decades since the appearance of the books by Knuth and Wirth. Although there are several advanced and special-
ized texts and handbooks on algorithms (and related data structures), there is, to the best of our knowledge, no text or handbook
that focuses exclusively on the wide variety of data structures that have been reported in the literature. The goal of this handbook
is to provide a comprehensive survey of data structures of different types that are in existence today.
To this end, we have subdivided this handbook into seven parts, each of which addresses a different facet of data structures.
Part I is a review of introductory material. Although this material is covered in all standard data structures texts, it was included
to make the handbook self-contained and in recognition of the fact that there are many practitioners and programmers who
may not have had a formal education in computer science. Parts II through IV discuss Priority Queues, Dictionary Structures,
and Multidimensional structures, respectively. These are all well-known classes of data structures. Part V is a catch-all used for
well-known data structures that eluded easy classification. Parts I through V are largely theoretical in nature: they discuss the data
structures, their operations and their complexities. Part VI addresses mechanisms and tools that have been developed to facilitate
the use of data structures in real programs. Many of the data structures discussed in previous parts are very intricate and take
some effort to program. The development of data structure libraries and visualization tools by skilled programmers are of critical
importance in reducing the gap between theory and practice. Finally, Part VII examines applications of data structures. The
deployment of many data structures from Parts I through V in a variety of applications is discussed. Some of the data structures
discussed here have been invented solely in the context of these applications and are not well-known to the broader community.
Some of the applications discussed include Internet routing, web search engines, databases, data mining, scientific computing,
geographical information systems, computational geometry, computational biology, VLSI floorplanning and layout, computer
graphics and image processing.
For data structure and algorithm researchers, we hope that the handbook will suggest new ideas for research in data structures
and for an appreciation of the application contexts in which data structures are deployed. For the practitioner who is devising
an algorithm, we hope that the handbook will lead to insights in organizing data that make it possible to solve the algorithmic
problem more cleanly and efficiently. For researchers in specific application areas, we hope that they will gain some insight from
the ways other areas have handled their data structuring problems.
Although we have attempted to make the handbook as complete as possible, it is impossible to undertake a task of this mag-
nitude without some omissions. For this, we apologize in advance and encourage readers to contact us with information about
significant data structures or applications that do not appear here. These could be included in future editions of this handbook.
We would like to thank the excellent team of authors, who are at the forefront of research in data structures, who have contributed
to this handbook. The handbook would not have been possible without their painstaking efforts. We are extremely saddened by
the untimely demise of a prominent data structures researcher, Professor Gísli R. Hjaltason, who was to write a chapter for this
handbook. He will be missed greatly by the computer science community. Finally, we would like to thank our families for their
support during the development of the handbook.

Dinesh P. Mehta
Sartaj Sahni
April 2004

xiii
xiv Preface to the First Edition

MATLAB R
is a registered trademark of The MathWorks, Inc. For product information, please contact:
The MathWorks, Inc.
3 Apple Hill Drive
Natick, MA 01760-2098 USA Tel: 508 647 7000
Fax: 508-647-7001
E-mail: info@mathworks.com
Web: www.mathworks.com
Editors

Dinesh P. Mehta has been on the faculty of the Colorado School of Mines since 2000, where he is currently professor in the
Department of Computer Science. He earned degrees (all in computer science) from the Indian Institute of Technology Bombay,
the University of Minnesota, and the University of Florida. Before joining Mines in 2000, he was on the faculty of the University
of Tennessee Space Institute, where he received the Vice President’s Award for Teaching Excellence in 1997. He was a visiting
professor at Intel’s Strategic CAD Labs for several months in 1996 and 1997 and at the Tata Research Development and Design
Center (in Pune, India) in 2007. He has also received graduate teaching awards at Mines in 2007, 2008, and 2009.
He was assistant department head from 2004 to 2008 and interim department head from 2008 to 2010 in the former Depart-
ment of Mathematical and Computer Sciences and served as president of the Mines Faculty Senate in 2016–2017.
Dr. Mehta is the coauthor of the book, Fundamentals of Data Structures in C++ and coeditor of the Handbook of Algorithms
for VLSI Physical Design Automation. He serves as associate director of the ORwE (Operations Research with Engineering) PhD
program at Mines and is currently an associate editor of ACM Computing Surveys. His current research interests are in chemin-
formatics, computational materials, and big graph analytics.
Sartaj Sahni is a distinguished professor of computer and information sciences and engineering at the University of Florida. He
is also a member of the European Academy of Sciences, a Fellow of IEEE, ACM, AAAS, and Minnesota Supercomputer Institute,
and a distinguished alumnus of the Indian Institute of Technology, Kanpur. Dr. Sahni is the recipient of the 1997 IEEE Computer
Society Taylor L. Booth Education Award, the 2003 IEEE Computer Society W. Wallace McDowell Award, and the 2003 ACM Karl
Karlstrom Outstanding Educator Award. Dr. Sahni earned his BTech (electrical engineering) degree from the Indian Institute of
Technology, Kanpur, and MS and PhD in computer science from Cornell University. Dr. Sahni has published over 400 research
papers and written 15 books. His research publications are on the design and analysis of efficient algorithms, parallel computing,
interconnection networks, design automation, and medical algorithms.
Dr. Sahni is the editor-in-chief of the ACM Computing Surveys, a managing editor of the International Journal of Foundations
of Computer Science, and a member of the editorial boards of 17 other journals. He is a past coeditor-in-chief of the Journal of
Parallel and Distributed Computing. He has served as program committee chair, general chair, and a keynote speaker at many
conferences. Dr. Sahni has served on several NSF (National Science Foundation) and NIH (National Institutes of Health) panels
and he has been involved as an external evaluator of several computer science and engineering departments.

xv
Contributors

Srinivas Aluru Siu-Wing Cheng


Georgia Institute of Technology The Hong Kong University of Science
Atlanta, Georgia and Technology
Kowloon, Hong Kong
Arne Andersson
Uppsala University Camil Demetrescu
Uppsala, Sweden Sapienza University of Rome
Rome, Italy
Lars Arge
University of Aarhus Narsingh Deo
Aarhus, Denmark University of Central Florida
Orlando, Florida
Sunil Arya
The Hong Kong University of Science Sumeet Dua
and Technology Louisiana Tech University
Kowloon, Hong Kong Ruston, Louisiana

Surender Baswana Christian A. Duncan


Indian Institute of Technology, Kanpur Quinnipiac University
Kanpur, India Hamden, Connecticut

Mark de Berg Peter Eades


Eindhoven University of Technology University of Sydney
Eindhoven, The Netherlands Sydney, Australia

Gerth Stølting Brodal Andrzej Ehrenfeucht


University of Aarhus University of Colorado
Aarhus, Denmark Boulder, Colorado

Bernard Chazelle Rolf Fagerberg


Department of Computer Science University of Southern Denmark
Princeton University Odense, Denmark
Princeton, New Jersey
Zhou Feng
John D. Crabtree Fudan University
Department of Computer Science Shanghai, China
and Information Systems
University of North Alabama Paolo Ferragina
Florence, Alabama Università di Pisa
Pisa, Italy
Shigang Chen
Computer and Information Science Irene Finocchi
and Engineering Department of Computer Science
University of Florida Sapienza University of Rome
Gainesville, Florida Rome, Italy

Chung-Kuan Cheng Michael L. Fredman


University of California Rutgers University
San Diego, California New Brunswick, New Jersey

xvii
xviii Contributors

Teofilo F. Gonzalez Kim S. Larsen


Department of Computer Science University of Southern Denmark
University of California Odense, Denmark
Santa Barbara, California
D. T. Lee
Michael T. Goodrich Institute of Information Science
University of California Academia Sinica
Irvine, California Taipei, Taiwan

Leonidas Guibas Scott Leutenegger


Stanford University Department of Computer Science
Palo Alto, California University of Denver
Denver, Colorado
Prosenjit Gupta
Ming C. Lin
Department of Computer Science
University of North Carolina
and Engineering
Chapel Hill, North Carolina
NIIT University
Rajasthan, India
Stefano Lonardi
University of California, Riverside
Monika Henzinger Riverside, California
University of Vienna
Vienna, Austria Mario A. Lopez
Department of Computer Science
Seok-Hee Hong University of Denver
University of Sydney Denver, Colorado
Sydney, Australia
S. N. Maheshwari
Giuseppe F. Italiano Indian Institute of Technology Delhi
Department of Civil Engineering Delhi, India
and Computer Science Engineering
University of Rome Dinesh Manocha
Tor Vergata Rome, Italy University of North Carolina
Chapel Hill, North Carolina
S. S. Iyengar
Florida International University Giovanni Manzini
Miami, Florida Università del Piemonte Orientale
Vercelli VC, Italy
Ravi Janardan
Department of Computer Science and Engineering Ross M. McConnell
University of Minnesota Colorado State University
Minneapolis, Minnesota Fort Collins, Colorado

Dinesh P. Mehta
Haim Kaplan
Department of Computer Science
Tel Aviv University
Colorado School of Mines
Tel Aviv, Israel
Golden, Colorado

Vipin Kumar Shin-ichi Minato


University of Minnesota Hokkaido University
Minneapolis, Minnesota Sapporo, Japan

Stefan Kurtz Pat Morin


University of Hamburg Carleton University
Hamburg, Germany Ottawa, Ontario, Canada
Contributors xix

David M. Mount Institute for Advanced Computer Studies


University of Maryland University of Maryland
College Park, Maryland College Park, Maryland

J. Ian Munro Sanjeev Saxena


University of Waterloo Department of Computer Science & Engineering
Waterloo, Ontario, Canada Indian Institute of Technology, Kanpur
Kanpur, India
Stefan Naeher
Department of Computer Science Markus Schneider
University of Trier University of Florida
Trier, Germany Gainesville, Florida
Chris Okasaki
Bernhard Seeger
United States Military Academy
University of Marburg
West Point, New York
Marburg, Germany
Alex Pothen
Computer Science Department Purdue University Sandeep Sen
West Lafayette, Indiana Indian Institute of Technology, Delhi
New Delhi, India
Saladi Rahul
Department of Computer Science Michiel Smid
University of Illinois School of Computer Science
Urbana, Illinois Carleton University
Ottawa, Ontario, Canada
Rajeev Raman
University of Leicester Bettina Speckmann
Leicester, United Kingdom Eindhoven University of Technology
Eindhoven, The Netherlands
C. Pandu Rangan
Indian Institute of Technology, Madras John Stasko
Chennai, India School of Interactive Computing
Georgia Institute of Technology
S. Srinivasa Rao Atlanta, Georgia
Seoul National University
Seoul, South Korea Michael Steinbach
University of Minnesota
Arun A. Ravindran Minneapolis, Minnesota
Department of Electrical and Computer Engineering
University of North Carolina at Charlotte Roberto Tamassia
Charlotte, North Carolina Brown University
Providence, Rhode Island
Wojciech Rytter
Warsaw University Pang-Ning Tan
Warsaw, Poland Michigan State University
East Lansing, Michigan
Sartaj Sahni
University of Florida Sivan Toledo
Gainesville, Florida Tel Aviv University
Tel Aviv, Israel
Hanan Samet
Computer Science Department Luca Vismara
Center for Automation Research Brown University, Providence
and Rhode Island
xx Contributors

Jeffrey Scott Vitter Bo Yao


Department of Computer and Information Science University of California
The University of Mississippi San Diego, California
Oxford, Mississippi
Hung-I Yu
Mark Allen Weiss Institute of Information Science
Florida International University Academia Sinica
Miami, Florida Taipei, Taiwan

Peter Widmayer
ETH Zürich
Zürich, Switzerland
I
Fundamentals
1 Analysis of Algorithms Sartaj Sahni ..............................................................................................................................3
Introduction • Operation Counts • Step Counts • Counting Cache Misses • Asymptotic
Complexity • Recurrence Equations • Amortized Complexity • Practical Complexities •
Acknowledgments • References

2 Basic Structures Dinesh P. Mehta.................................................................................................................................23


Introduction • Arrays • Linked Lists • Stacks and Queues • Acknowledgments • References

3 Trees Dinesh P. Mehta ....................................................................................................................................................35


Introduction • Tree Representation • Binary Trees and Properties • Binary Tree Traversals •
Threaded Binary Trees • Binary Search Trees • Heaps • Tournament Trees • Acknowledgments •
References

4 Graphs Narsingh Deo ....................................................................................................................................................49


Introduction • Graph Representations • Connectivity, Distance, and Spanning Trees • Searching a
Graph • Simple Applications of DFS and BFS • Minimum Spanning Tree • Shortest Paths •
Eulerian and Hamiltonian Graphs • Acknowledgments • References

1
1
Analysis of Algorithms*
1.1 Introduction...................................................................................................................... 3
1.2 Operation Counts............................................................................................................. 4
1.3 Step Counts ....................................................................................................................... 5
1.4 Counting Cache Misses.................................................................................................... 7
A Simple Computer Model • Effect of Cache Misses on Run Time • Matrix Multiplication
1.5 Asymptotic Complexity ................................................................................................... 9
Big Oh Notation (O) • Omega () and Theta () Notations • Little Oh Notation (o)
1.6 Recurrence Equations .................................................................................................... 12
Substitution Method • Table-Lookup Method
1.7 Amortized Complexity................................................................................................... 14
What Is Amortized Complexity? • Maintenance Contract • The McWidget Company •
Subset Generation
1.8 Practical Complexities.................................................................................................... 20
Sartaj Sahni Acknowledgments ..................................................................................................................... 21
University of Florida References................................................................................................................................... 21

1.1 Introduction
The topic “Analysis of Algorithms” is concerned primarily with determining the memory (space) and time requirements
(complexity) of an algorithm. Since the techniques used to determine memory requirements are a subset of those used
to determine time requirements, in this chapter, we focus on the methods used to determine the time complexity of an
algorithm.
The time complexity (or simply, complexity) of an algorithm is measured as a function of the problem size. Some examples
are given below.

1. The complexity of an algorithm to sort n elements may be given as a function of n.


2. The complexity of an algorithm to multiply an m × n matrix and an n × p matrix may be given as a function of m,
n, and p.
3. The complexity of an algorithm to determine whether x is a prime number may be given as a function of the number, n,
of bits in x. Note that n = log2 (x + 1).

We partition our discussion of algorithm analysis into the following sections.

1. Operation counts
2. Step counts
3. Counting cache misses
4. Asymptotic complexity
5. Recurrence equations
6. Amortized complexity
7. Practical complexities

See [1–4] for additional material on algorithm analysis.

* This chapter has been reprinted from first edition of this Handbook, without any content updates.

3
4 Handbook of Data Structures and Applications

1.2 Operation Counts


One way to estimate the time complexity of a program or method is to select one or more operations, such as add, multiply,
and compare, and to determine how many of each is done. The success of this method depends on our ability to identify the
operations that contribute most to the time complexity.

EXAMPLE 1.1
[Max Element] Figure 1.1 gives an algorithm that returns the position of the largest element in the array a[0:n-1].
When n > 0, the time complexity of this algorithm can be estimated by determining the number of comparisons made
between elements of the array a. When n ≤ 1, the for loop is not entered. So no comparisons between elements of a
are made. When n > 1, each iteration of the for loop makes one comparison between two elements of a, and the total
number of element comparisons is n-1. Therefore, the number of element comparisons is max{n-1, 0}. The method max
performs other comparisons (e.g., each iteration of the for loop is preceded by a comparison between i and n) that are
not included in the estimate. Other operations such as initializing positionOfCurrentMax and incrementing the for
loop index i are also not included in the estimate.

int max(int [] a, int n)


{
if (n < 1) return -1; // no max
int positionOfCurrentMax = 0;
for (int i = 1; i < n; i++)
if (a[positionOfCurrentMax] < a[i]) positionOfCurrentMax = i;
return positionOfCurrentMax;
}

FIGURE 1.1 Finding the position of the largest element in a[0:n-1].

The algorithm of Figure 1.1 has the nice property that the operation count is precisely determined by the problem size.
For many other problems, however, this is not so. Figure 1.2 gives an algorithm that performs one pass of a bubble sort. In
this pass, the largest element in a[0:n-1] relocates to position a[n-1]. The number of swaps performed by this algorithm
depends not only on the problem size n but also on the particular values of the elements in the array a. The number of
swaps varies from a low of 0 to a high of n − 1.

void bubble(int [] a, int n)


{
for (int i = 0; i < n - 1; i++)
if (a[i] > a[i+1]) swap(a[i], a[i+1]);
}

FIGURE 1.2 A bubbling pass.

Since the operation count isn’t always uniquely determined by the problem size, we ask for the best, worst, and average
counts.

EXAMPLE 1.2
[SEQUENTIAL SEARCH] Figure 1.3 gives an algorithm that searches a[0:n-1] for the first occurrence of x. The number
of comparisons between x and the elements of a isn’t uniquely determined by the problem size n. For example, if n = 100
and x = a[0], then only 1 comparison is made. However, if x isn’t equal to any of the a[i]s, then 100 comparisons are
made.
A search is successful when x is one of the a[i]s. All other searches are unsuccessful. Whenever we have an unsuccessful
search, the number of comparisons is n. For successful searches the best comparison count is 1, and the worst is n. For the
average count assume that all array elements are distinct and that each is searched for with equal frequency. The average
Analysis of Algorithms 5

count for a successful search is


1
n
i = (n + 1)/2
n
i=1

int sequentialSearch(int [] a, int n, int x)


{
// search a[0:n-1] for x
int i;
for (i = 0; i < n && x != a[i]; i++);
if (i == n) return -1; // not found
else return i;
}

FIGURE 1.3 Sequential search.

EXAMPLE 1.3
[Insertion into a Sorted Array] Figure 1.4 gives an algorithm to insert an element x into a sorted array
a[0:n-1].
We wish to determine the number of comparisons made between x and the elements of a. For the problem size, we
use the number n of elements initially in a. Assume that n ≥ 1. The best or minimum number of comparisons is 1, which
happens when the new element x

void insert(int [] a, int n, int x)


{
// find proper place for x
int i;
for (i = n - 1; i >= 0 && x < a[i]; i--)
a[i+1] = a[i];

a[i+1] = x; // insert x
}

FIGURE 1.4 Inserting into a sorted array.

is to be inserted at the right end. The maximum number of comparisons is n, which happens when x is to be inserted at
the left end. For the average assume that x has an equal chance of being inserted into any of the possible n+1 positions. If
x is eventually inserted into position i+1 of a, i ≥ 0, then the number of comparisons is n-i. If x is inserted into a[0],
the number of comparisons is n. So the average count is
n−1  ⎛ ⎞
1  1 ⎝
n
1 n(n + 1) n n
(n − i) + n = j + n⎠ = +n = +
n+1 n+1 n+1 2 2 n+1
i=0 j=1

This average count is almost 1 more than half the worst-case count.

1.3 Step Counts


The operation-count method of estimating time complexity omits accounting for the time spent on all but the chosen operations.
In the step-count method, we attempt to account for the time spent in all parts of the algorithm. As was the case for operation
counts, the step count is a function of the problem size.
A step is any computation unit that is independent of the problem size. Thus 10 additions can be one step; 100 multiplications
can also be one step; but n additions, where n is the problem size, cannot be one step. The amount of computing represented by
one step may be different from that represented by another. For example, the entire statement
return a+b+b*c+(a+b-c)/(a+b)+4;
6 Handbook of Data Structures and Applications

TABLE 1.1 Best-Case Step Count for Figure 1.3


Statement s/e Frequency Total Steps
int sequentialSearch(··· ) 0 0 0
{ 0 0 0
int i; 1 1 1
for (i = 0; i < n && x != a[i]; i++); 1 1 1
if (i == n) return -1; 1 1 1
else return i; 1 1 1
} 0 0 0
Total 4

TABLE 1.2 Worst-Case Step Count for Figure 1.3


Statement s/e Frequency Total Steps
int sequentialSearch(··· ) 0 0 0
{ 0 0 0
int i; 1 1 1
for (i = 0; i < n && x != a[i]; i++); 1 n+1 n+1
if (i == n) return -1; 1 1 1
else return i; 1 0 0
} 0 0 0
Total n+3

TABLE 1.3 Step Count for Figure 1.3 When x = a[j]


Statement s/e Frequency Total Steps
int sequentialSearch(··· ) 0 0 0
{ 0 0 0
int i; 1 1 1
for (i = 0; i < n && x != a[i]; i++); 1 j+1 j+1
if (i == n) return -1; 1 1 1
else return i; 1 1 1
} 0 0 0
Total j+4

can be regarded as a single step if its execution time is independent of the problem size. We may also count a statement such as
x = y;

as a single step.
To determine the step count of an algorithm, we first determine the number of steps per execution (s/e) of each statement
and the total number of times (i.e., frequency) each statement is executed. Combining these two quantities gives us the total
contribution of each statement to the total step count. We then add the contributions of all statements to obtain the step count
for the entire algorithm.

EXAMPLE 1.4
[Sequential Search] Tables 1.1 and 1.2 show the best- and worst-case step-count analyses for sequentialSearch
(Figure 1.3).
For the average step-count analysis for a successful search, we assume that the n values in a are distinct and that in a
successful search, x has an equal probability of being any one of these values. Under these assumptions the average step
count for a successful search is the sum of the step counts for the n possible successful searches divided by n. To obtain this
average, we first obtain the step count for the case x = a[j] where j is in the range [0, n − 1] (see Table 1.3).
Analysis of Algorithms 7

Now we obtain the average step count for a successful search:

1
n−1
(j + 4) = (n + 7)/2
n
j=0

This value is a little more than half the step count for an unsuccessful search.
Now suppose that successful searches occur only 80% of the time and that each a[i] still has the same probability of
being searched for. The average step count for sequentialSearch is

0.8 ∗ (average count for successful searches) + 0.2 ∗ (count for an unsuccessful search)
= 0.8(n + 7)/2 + 0.2(n + 3)
= 0.6n + 3.4

1.4 Counting Cache Misses


1.4.1 A Simple Computer Model
Traditionally, the focus of algorithm analysis has been on counting operations and steps. Such a focus was justified when com-
puters took more time to perform an operation than they took to fetch the data needed for that operation. Today, however, the
cost of performing an operation is significantly lower than the cost of fetching data from memory. Consequently, the run time of
many algorithms is dominated by the number of memory references (equivalently, number of cache misses) rather than by the
number of operations. Hence, algorithm designers focus on reducing not only the number of operations but also the number of
memory accesses. Algorithm designers focus also on designing algorithms that hide memory latency.
Consider a simple computer model in which the computer’s memory consists of an L1 (level 1) cache, an L2 cache, and main
memory. Arithmetic and logical operations are performed by the arithmetic and logic unit (ALU) on data resident in registers
(R). Figure 1.5 gives a block diagram for our simple computer model.
Typically, the size of main memory is tens or hundreds of megabytes; L2 cache sizes are typically a fraction of a megabyte; L1
cache is usually in the tens of kilobytes; and the number of registers is between 8 and 32. When you start your program, all your
data are in main memory.
To perform an arithmetic operation such as an add, in our computer model, the data to be added are first loaded from memory
into registers, the data in the registers are added, and the result is written to memory.
Let one cycle be the length of time it takes to add data that are already in registers. The time needed to load data from L1 cache
to a register is two cycles in our model. If the required data are not in L1 cache but are in L2 cache, we get an L1 cache miss and
the required data are copied from L2 cache to L1 cache and the register in 10 cycles. When the required data are not in L2 cache
either, we have an L2 cache miss and the required data are copied from main memory into L2 cache, L1 cache, and the register in
100 cycles. The write operation is counted as one cycle even when the data are written to main memory because we do not wait
for the write to complete before proceeding to the next operation. For more details on cache organization, see [5].

1.4.2 Effect of Cache Misses on Run Time


For our simple model, the statement a = b + c is compiled into the computer instructions
load a; load b; add; store c;

where the load operations load data into registers and the store operation writes the result of the add to memory. The add
and the store together take two cycles. The two loads may take anywhere from 4 cycles to 200 cycles depending on whether
we get no cache miss, L1 misses, or L2 misses. So the total time for the statement a = b + c varies from 6 cycles to 202 cycles.
In practice, the variation in time is not as extreme because we can overlap the time spent on successive cache misses.

ALU
main
L2 memory
R L1

FIGURE 1.5 A simple computer model.


8 Handbook of Data Structures and Applications

Suppose that we have two algorithms that perform the same task. The first algorithm does 2000 adds that require 4000 load,
2000 add, and 2000 store operations and the second algorithm does 1000 adds. The data access pattern for the first algorithm
is such that 25% of the loads result in an L1 miss and another 25% result in an L2 miss. For our simplistic computer model, the
time required by the first algorithm is 2000 ∗ 2 (for the 50% loads that cause no cache miss) + 1000 ∗ 10 (for the 25% loads that
cause an L1 miss) + 1000 ∗ 100 (for the 25% loads that cause an L2 miss) + 2000 ∗ 1 (for the adds) + 2000 ∗ 1 (for the stores)
= 118,000 cycles. If the second algorithm has 100% L2 misses, it will take 2000 ∗ 100 (L2 misses) + 1000 ∗ 1 (adds) + 1000 ∗ 1
(stores) = 202,000 cycles. So the second algorithm, which does half the work done by the first, actually takes 76% more time
than is taken by the first algorithm.
Computers use a number of strategies (such as preloading data that will be needed in the near future into cache, and when a
cache miss occurs, the needed data as well as data in some number of adjacent bytes are loaded into cache) to reduce the number
of cache misses and hence reduce the run time of a program. These strategies are most effective when successive computer
operations use adjacent bytes of main memory.
Although our discussion has focused on how cache is used for data, computers also use cache to reduce the time needed to
access instructions.

1.4.3 Matrix Multiplication


The algorithm of Figure 1.6 multiplies two square matrices that are represented as two-dimensional arrays. It performs the fol-
lowing computation:
n
c[i][j] = a[i][k] ∗ b[k][j], 1 ≤ i ≤ n, 1 ≤ j ≤ n (1.1)
k=1

Figure 1.7 is an alternative algorithm that produces the same two-dimensional array c as is produced by Figure 1.6. We observe
that Figure 1.7 has two nested for loops that are not present in Figure 1.6 and does more work than is done by Figure 1.6 with
respect to indexing into the array c. The remainder of the work is the same.
You will notice that if you permute the order of the three nested for loops in Figure 1.7, you do not affect the result array c.
We refer to the loop order in Figure 1.7 as ijk order. When we swap the second and third for loops, we get ikj order. In all,
there are 3! = 6 ways in which we can order the three nested for loops. All six orderings result in methods that perform exactly

void squareMultiply(int [][] a, int [][] b, int [][] c, int n)


{
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
{
int sum = 0;
for (int k = 0; k < n; k++)
sum += a[i][k] * b[k][j];
c[i][j] = sum;
}
}

FIGURE 1.6 Multiply two n × n matrices.

void fastSquareMultiply(int [][] a, int [][] b, int [][] c, int n)


{
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
c[i][j] = 0;

for (int i = 0; i < n; i++)


for (int j = 0; j < n; j++)
for (int k = 0; k < n; k++)
c[i][j] += a[i][k] * b[k][j];
}

FIGURE 1.7 Alternative algorithm to multiply square matrices.


Another random document with
no related content on Scribd:
In the Council’s collection are:—
[418]Ornamental plaster ceiling in Board Room on first floor
(photograph).
[418]Carved deal chimneypiece in Board Room (photograph).
[418]Ornamental plaster ceiling in Grand Secretary’s Room, first floor
(photograph).
XL.—GREAT QUEEN STREET CHAPEL
(Demolished).
General description and date of
structure.
Before its destruction in 1910 the Wesleyan Chapel in Great
Queen Street occupied the greater portion of the sites of three houses
with their gardens. These were Nos. 66 to 68, intervening between
Conway House and the stream which divided Aldwych Close from
Purse Field.
The land on which these three houses were erected was
roughly the shape of a truncated right-angled triangle, the base of
which was represented by Great Queen Street, the perpendicular by
the line of Middle Yard, and the hypotenuse by the course of the
stream. The land in question was leased[419] by Newton to Peter
Mills[420], of Christchurch, London, bricklayer, and it would seem
that at that date (15th September, 1639) no houses had been erected
thereon.[421] The building was therefore carried out probably in 1640;
at any rate No. 66 is known to have been occupied in December,
1641. No information can be gleaned from the ratebooks as to when
the three houses were rebuilt, but at least one (No. 67) seems to have
been still standing at about 1817, when an illustration of it was
included in Parton’s Hospital and Parish of St. Giles-in-the-Fields.
The first reference that has been found to the building of a
chapel of ease for the parish occurs in the Vestry Minutes under the
year 1693:[422] “Ordered, to inquire of the gentry in Lincoln’s Inn
Fields, which of them will take pews in case a chappell should be
erected in the neighbourhood of Lincoln’s Inn Fields, and report to
be made to the next Vestry.” It was, however, left to private
enterprise to provide such a building.
In 1706 a Mr. Baguley took a house (apparently No. 67)[423],
built a chapel in the rear, and seems even to have officiated therein,
although not in Priest’s orders. Naturally enough, he soon got into
trouble with the Rector of St. Giles, who, as Baguley affirmed,[424]
induced the vendor of the house and land to break off his agreement
with Baguley, and sell to “one Burges, a coachmaker.” According,
however, to the ratebooks the house occupied by Burges was No. 68.
Between 1720 and 1723 the assessment of No. 68 also dropped.
Whether this implies an extension of the chapel over a portion of the
ground in the rear of that house is uncertain, but it will be seen that
when the chapel comes, as it were, into the light of day, at the
beginning of the 19th century, it covers nearly the whole of the rear
of both houses.
The whole of its early history, however, is shrouded in
obscurity, and no reference to it or to the services held therein has
been found between 1728[425] and its acquisition by the Rev. Thomas
Francklyn. Even the date at which this occurred cannot be definitely
stated. The chapel seems to have been in his hands in February,
1758, for on the 17th of that month he preached a sermon there,
which he published in the same year.[426] In 1759 his name appears in
the parish ratebook in connection with the chapel.[427] His residence
at the house (No. 67) does not seem to have begun until 1761. On
Francklyn’s death in 1784, his executors appear to have carried on
the work of the chapel. On 19th July, 1798, Mrs. Francklyn’s
executors sold to the Society formerly carrying on the West Street
Chapel, Seven Dials, their leasehold interest in the two houses and
the chapel for £3,507 10s.[428]
The chapel was at that time, says Blott,[429] a very homely
structure; it was dark, and, lying below the level of the street, could
not easily be kept clean, and the entrance to it was by a passage
through a dwelling house. The surrounding houses overlooking it
were at times a means of annoyance during service. Negotiations
were therefore entered into with the owners of No. 66, and on 14th
March, 1815, a purchase was effected of the whole of the back part of
the premises, bounded by Middle Yard on the one side and the old
chapel on the other, and having a length of 102½ feet and a breadth
of 31 feet.[430] The new chapel was opened on 25th September, 1817.
[431]
Alterations were carried out in 1840, when an improved frontage
and new portico were constructed.[432]
The elevation to Great Queen Street (Plate 32) was of brick
faced with stucco, the lower part having a portico of four Greek Ionic
columns the full width of the building, executed in Talacre stone
from North Wales.[432] Above this, in the main wall of the chapel was
a three light window with Corinthian columns and pilasters
supporting an entablature, over which was a semi-circular pediment
and tympanum. Crowning the whole was a bold modillion cornice.
The interior (Plate 33) had a horseshoe gallery supported by
Ionic columns; above the back of the side galleries were other
smaller galleries. Facing the entrance was an apse ornamented with
Corinthian columns, pilasters and entablature carrying an elliptical
arch. Covering the whole area was a flat ornamental ceiling.
There is preserved by the West London Mission a measured
drawing of the elevation of the Chapel to Great Queen Street with the
adjacent buildings by R. Payne, Architect, June 21 (18)56, and an
internal view in perspective drawn with ink and coloured, probably
executed by the same hand and about the same date. Both these
drawings agree with the illustrations taken in 1906, and reproduced
in Plates 32 and 33. The premises were demolished in 1910, and new
buildings erected. The room over the portico was used at first as a
day school room, but in 1860 the school was removed to new
premises in the rear.
Biographical Notes.
No. 66.
The first occupant of No. 66, of whom any record has been found,
was the Countess of Essex, who was there in December, 1641.[433] This was
Elizabeth, the daughter of Sir William Paulet, who, in 1631, became the
second wife of Robert Devereux, third Earl of Essex. The marriage turned
out very unhappily, and eventually a separation took place. Subsequently
she married Thomas Higgons (knighted after her death), who survived her.
She died in 1656.[434]
The Subsidy Roll for 1646 contains the item: “The Lord Kensington
in the Countes of Essex house.” This was presumably Robert Rich, son of
Henry Rich, first Earl of Holland, the latter having been created Baron
Kensington in 1623. The former in 1673 succeeded his cousin Charles, as
fifth Earl of Warwick.
In 1665 and 1666 Magdalen Elliott is shown at the house, and in 1673
Lady Porter. The entries in the Hearth Tax Rolls, Jury Presentment Rolls
and sewer ratebook from this time until 1700 vary between “Lady Porter,”
“Lady Diana Portland,” and “Lady Ann Porter.” There can be no doubt that
they all refer to the same individual, viz., Lady Diana Porter. She was a
daughter of George Goring, Earl of Norwich, and married (1) Thomas
Covert, of Slaugham, Essex, and (2) George Porter,[435] eldest son of
Endymion Porter, royalist and patron of literature. George Porter served as
lieutenant-general in the western royal army, under the command of his
brother-in-law, Lord Goring. The latter described him as “the best company,
but the worst officer that ever served the king.” Porter died in 1683.
The ratebook for 1703 contains the name “Ralph Lane” crossed out,
and “Wortley” substituted. This seems to point to Lane having recently
moved and “Wortley” taken his place. The “Ralph Lane” in question is no
doubt the person of the same name, who had in the previous year purchased
the house to the west of Conway House (see p. 74). His residence at No. 66
could not have lasted more than about two years. The “Wortley” of the 1703
ratebook is expanded in the records of 1709 and 1715 to “Wortley Montague,
Esq.” and “Sidney Wortley als Montague, Esq.” This was Sidney, second son
of Edward Montagu, first Earl of Sandwich, who married Anne, daughter
and heir of Sir Francis Wortley, Bt., and assumed the surname of Wortley.
His eldest son, Edward Wortley Montagu, married Lady Mary Pierrepont,
the famous Lady Mary Wortley Montagu. Sidney Montagu died in 1727.
After Montagu’s residence the occupiers of No. 66 seem to have been
as follows:—
Before 1720 until after 1723. Martin Wright.
Before 1730. Elizabeth Perry.
1730–42. William Aspin.
1743–45. Dr. John Taylor.
1746. —— Davis.
1747. Lilley Smith.
1748. “Augusti” Arne.
1749–51. Col. Guy Dickens.
1753–61. Elizabeth Falconer.
1761–62. —— Davis.
1762–63. The Rev. Mr. Francklin.
1763–64. Miss Faulkner.
1764–83. —— Davis.
1783–87. —— Saunders.
1789–94. Ric. Sadler.
1795– J. Savage.

“Augusti” Arne is almost certainly Thomas Augustine Arne, the


celebrated composer. He was the son of Thomas Arne, an upholsterer, and
was born in 1710. On leaving school he was placed in a lawyer’s office, but
his love of music overcame all obstacles, and eventually his father was
induced to allow him to cultivate his talent in this respect. His first work, a
setting of Addison’s Rosamond, was produced at Lincoln’s Inn Fields
Theatre in 1733. This proving successful, it was quickly followed by the
Opera of Operas and Dido and Æneas. In 1738 he established his
reputation by his music to Comus, and in 1740 he wrote the music to
Thomson and Mallet’s Masque of Alfred, containing Rule Britannia. His
later works included the songs Where the bee sucks, Under the greenwood
tree, Blow, blow, thou winter wind, the oratorios Abel and Judith, and the
opera Artaxerxes. In 1769 he set to music the ode by Garrick, performed at
the Shakespeare jubilee at Stratford on Avon. He died in 1778.
No allusions have been found to his residence at No. 66, Great Queen
Street. He is stated to have been living “next door to the Crown in Great
Queen Street,” in 1744[436] but that must refer to a different house. The
sewer ratebook for 1734 shows a “Mr. Arne” resident at No. 34, Great Queen
Street, but there is no proof that this was the musician. His residence at No.
215, King’s Road, Chelsea, has already been mentioned.[437]

No. 67.
Early records of the residents at No. 67 are wanting. The first
mention of the house occurs in the Hearth Tax Roll for 1665, which gives
“Lady Thimbleby” as the occupier. This was Elizabeth, one of the six
daughters of Sir Thomas Savage and Elizabeth, Countess Rivers (see p. 67).
She married Sir John Thimbleby of Irnham, in Lincolnshire.[438] How long
she had been at No. 67 in 1665 is unknown, but it is permissible to suggest
that she was there while her mother was still living three doors away. It
seems likely that during Lady Thimbleby’s stay here, her sister, Henrietta
Maria, who had married Ralph Sheldon, of Beoley,[439] also came to live
close by, for the Jury Presentment Roll for 1683 shows “Ralph Sheldon,” in
occupation of No. 69. Another sister, Anne, who had married Robert
Brudenell, afterwards second Earl of Cardigan, was also only a short
distance away, on the south side of Lincoln’s Inn Fields.[440]
Lady Thimbleby’s residence lasted until between 1700 and 1703, and
in the latter year the name of John Thimbleby appears in respect of the
house. He had left before 1709, when the house is shown as empty. The
occupiers after that date were as follows:—

1715. Mr. Vaune.


1720. Mr. Froude.[441]
Before 1723 until 1734. Mary Forrester.
1735–51. Adam Hallam.
1751–54. William Pritchard.
1755–61. Stephen Hunt.
1761–84. The Rev. Thomas Francklin.
1784–95. Mrs. Francklin.
1795–98. Francis Const.[442]
1798. —— Rowley.

Thomas Francklin, son of Richard Francklin, a bookseller of Covent


Garden, was born in 1721. He was educated at Westminster School and
Trinity College, Cambridge. For some time he found employment as usher
in his old school, and in 1750 he became Greek professor at Cambridge, a
position which he held until 1759, when he was presented to the vicarage of
Ware. At the same time he was fulfilling other clerical duties in London. As
early as 1749 he seems to have held a chapel in Bloomsbury, for in June of
that year he performed the marriage ceremony for Garrick there.[443] By
1758 he had obtained the lectureship at St. Paul’s, Covent Garden, and was
installed in the Great Queen Street Chapel. He was appointed King’s
chaplain in 1767, and ten years later he vacated the living at Ware for the
rectory of Brasted, in Kent. Through the influence of Dr. Johnson and Sir
Joshua Reynolds, he was appointed chaplain to the Royal Academy, and on
the death of Goldsmith in 1774 he obtained the professorship of ancient
history. His literary output was considerable. In 1757 he brought out a
periodical paper called The Centinel, which only lasted two years. He wrote
four plays, the most important of which was The Earl of Warwick. His
translations were numerous, those of Sophocles’ tragedies being long
considered the best in the English language. After a laborious life he died in
his house in Great Queen Street[444] in March, 1784. His widow died in
1796.[445]

No. 68.

In the case of No. 68 also, no records of the names of any occupiers


exist before the Hearth Tax Roll for 1665. In that document the occupant’s
name is given as “Sir Willm. Hartupp.” This seems to have been Sir William
Hartopp, of Rotherby, son of Sir Thomas Hartopp, of Burton Lazars. Sir
William married Agnes, daughter of Sir Martin Lister.[446]
The Hearth Tax Roll for 1666 shows the house “Empty,” and that for
1672, “Empty—Mr. Bradshaw owner.” It seems probable that between these
dates occurred the joint occupancy of Lord Roos and Lady Chaworth, if
indeed that can be referred to this house at all. An item in Lord Roos’s
expenditure under date of 25th February, 1667–8, runs: “Paid Major Seales
for Sir William Hartopp for one quarter’s rent for the house in Queen Street,
beginning the 18th October, when his Lordship had the keyes, at 80li per
annum, Lady Ch[aworth] is to pay the next quarter, 20li.”[447] That Sir
William Hartopp’s house in 1667 was the same as that in 1665 is probable,
but unfortunately cannot be considered certain. Assuming, however, that
such is the case, Lord Roos’s occupation is seen to have commenced on 18th
October, 1667.
John Manners, third son of the eighth Earl of Rutland, was born in
1638. On the death of his two elder brothers, he assumed, apparently
without right,[448] the title of Lord Roos.[449] His first marriage, in 1658, to
Lady Anne Pierrepoint, was unhappy, and he was divorced from her by Act
of Parliament in 1670. In 1677 he was made Lord Lieutenant of
Leicestershire. He succeeded to the earldom in 1679. At the coronation of
James II. in 1685 he bore the Queen’s sceptre, but he does not seem to have
been in favour and in 1687 was dismissed from his lord lieutenancy. He
supported William at the Revolution, and was soon after restored to his
office. In 1703 he was created Marquess of Granby and Duke of Rutland. He
died in 1711.
His sister Grace married Patricius Chaworth, third Viscount
Chaworth.[450] Apparently the expenses of the house in Great Queen Street
were shared equally between her and her brother, for numerous items such
as the following occur in the Accounts of Lord Roos’s Expenditure
contained in the Duke of Rutland’s MSS.:—[451]
“1670. April 21. For the repaires of the parish church and maimed
soldiers, etc., this Queene Street house is taxed 5s., whereof Lady Chaworth
paying ½, his lordship ½, comes to 2s. 6d.”
“To the beadle for watching the Queene Street house ending the
above said Christmasse [1671] 4s.; Lady Cha[worth] paying ½, his lordship
other ½, comes to 2s.”
“July 3, 1669. The hire of paper windowes last year, 1668, to save the
hangings in the dining roome and drawing roome, the ½ of cost, Lady
Cha[worth] payes the other half, 5s.”
Some indication of the reason that influenced Lady Chaworth in
setting up housekeeping with her brother may be afforded from a letter
dated 25th June, 1670, from Lord Chaworth to his wife, at Lord Roos’s
house in Great Queen Street, requesting her to return to him, and offering
to receive her with respect and affection.[452]
In the Hearth Tax Roll for 1673, the house is shown as “Empty.” Two
years later “The Lady Morpeth” is shown in occupation. This was Elizabeth,
dowager lady Berkeley, wife of Edward Howard, Viscount Morpeth,
afterwards second Earl of Carlisle. It was in this same year that her eldest
son Charles, afterwards third earl, was born. Later occupants of the house
were:—
1683. Sir Edward Mosen.
Before 1698 until after 1709. Mrs. Eleanor Complin.
Before 1715 until after 1720. Thomas Burges.
Before 1723 until 1732. Ashburnham Froude and Thomas Burges.[453]
1733. Ashburnhame Froud.
1733–1740. Madame Eaton.
1740–44. Madame Pain (Paign).
1746. —— Davis.
1747–51. Elizabeth Falconer.
1753–55. James Ward.
1755–57. G. Stewart.
1758–70. Thos. Brock (Brooke).
1770–74. Thos. Rudd.
1775–78. Ric. Rudd.
1779. —— Thomas.
1780–86. Mrs. Thomas.
1786– John Arthur.
In the Council’s collection are:—
[454]Exterior(photograph).
Side entrance in Middle Yard, erected 1859–60 (photograph).
Interior from the gallery (photograph).
Interior looking south (photograph).
Interior looking north (photograph).
Fanlight under stairs (photograph).
Staircase (photograph).
Lantern light over staircase (photograph).
Loculi in crypt (photograph).
Two silver chalices dated MDCIIIC, originally presented for use in
West Street Chapel (photograph).
XLI.—SITE OF WELD HOUSE.

The history of that part of Aldwych Close lying within the


angle formed by Great Queen Street and Wild Street has already
been traced[455] up to the division of the greater portion of it between
Sir Edward Stradling and Sir Kenelm Digby in 1629. Eleven years
previously, Henry Holford had leased to John Ittery the extreme
southern portion, reaching 100 feet northwards from Sardinia Street,
and a trench had been dug separating Ittery’s portion from that lying
to the north. On the transfer of the latter to Sir W. Calley and Geo.
Strode in trust for Stradling and Digby, Ittery’s portion was included,
and added to Stradling’s share. Stradling without delay began the
erection on his portion of “a faire mansion house with stables and
other outhouses.”[456] On 12th December, 1632, the ground, with the
mansion, etc., was sold by Calley and Strode to Stradling, and was
then described as extending south from the partition wall[457]
between Digby’s and Stradling’s portions “together with that parte
formerly demised to the said John Ittery, and then enclosed together
with the same, at the end next Drewry Lane by a square lyne 300
foote, and at the other end next Lincolne’s Inne Feildes 296 foote.”
By 1632 Stradling had also divided his portion into two by a brick
wall, “beginninge at the west end towards Drewry Lane and
extendinge itselfe eastwards towards Lincolne’s Inne Feildes 144
foote, and then towards the north in length 132 foote, and then again
eastwards towards Lincolne’s Inne Feildes 132 foote, and standinge
distant at the west end thereof from the fore-mentioned partition
wall 157 foote, and at the other end next Lincolne’s Inne Feildes 31
foote.”[458]
On 20th December, 1632, Stradling sold that part lying to the
north of this second partition wall, including the house, etc., to
George Gage. The house had not yet been completed, but a provision
was subsequently made that Strode was to finish, before Easter,
1634, “the dwelling house and buildings now erected or begun to be
erected, within and without ... in all respects, fitt and necessary for
one or more dwelling house or houses.”[459]
The date of completion of the house may therefore be ascribed
with probability to the year 1634.
Gage used the house as his own residence, and while “lyeinge
sicke in the said messuage of the sickness whereof he died” made his
will on 14th August, 1638, bequeathing the premises,[460] together
with other property, to William Darrell and William Bierly to sell for
the payment of his debts. On 25th February, 1639–40, it was
purchased by Humphrey Weld for £2,600.[461]
The portion of Stradling’s property which lay to the south of
the second partition wall, and which extended to the southern limits
of Aldwych Close, Stradling seems to have sold to Dr. Gifford for 500
years for £400 without right of redemption.[462] In 1649 Andrew
Gifford sold the property for £650 to Weld, who assigned it to his
mother, Dame Frances Weld, in trust. Three years later she re-
assigned it to him.
Humphrey Weld thus became possessed of the whole of
Aldwych Close lying to the east of Wild Street, and to the south of the
gardens of the Great Queen Street houses, and he now began to
develop the property by building. A reference to Hollar’s Plan of 1658
(Plate 3) shows that by that year the whole of the east side of Wild
Street, south of Weld House, and all the north side of Sardinia Street
had been covered with houses.[463] Weld himself stated about 1670,
that he had by that time laid out £15,600 in building.[461]
The street which had at least since 1629,[464] and probably
since 1618,[465] led from Great Queen Street to Kemble Street, then
Princes Street, seems for some time to have been without a name. It
is referred to in early deeds as “the back side of Drury Lane,” “a way
leading from Princes Street to Queen Street on the back side of Drury
Lane,” etc. In the Subsidy Rolls up to 1646 inclusive, it is merged in
“Cockpit Side.” The earliest instance of the name Weld Street or Wild
Street[466] so far discovered is in a deed of 24th April, 1658,[467] which
refers to “the street now called Wild Street, but heretofore called a
way or passage of 40 foote breadth leading from Queenes Street to
Princes Streete.”
How far Weld House was identical with the mansion built by
Stradling and Strode is uncertain. Blott, after mentioning the latter,
says: “Adjoining it, on the south side, were the grounds and premises
of Weld House, Drury Lane, occupied by Lady Frances Weld, widow.
In 1657, Weld House and Stradling House underwent a complete
transformation, the two houses were united together and became
one building, having, besides extensive additions made to it, a
chapel[468] built in the garden; the front arranged to face Aldwyche
Close instead of Drury Lane, and an approach made to it called Weld
Street. This extraordinary enlargement was not to make the building
a residence suitable to the dignity of the Welds, but rather for State
purposes, such as the accommodation of princes and ambassadors in
London.”[469]
Blott gives no authority for his statements, one of which,
relating to the formation of Weld Street, is demonstrably wrong. The
statement that the “extraordinary enlargement” was carried out with
a view to the reception of princes and ambassadors in the building is
probably only an inference from the indisputable fact that
ambassadors did afterwards reside in a portion of the house.[470]
Nevertheless the view of the house given in Hollar’s Plan of 1658
(Plate 3) certainly does suggest the amalgamation of two distinct
houses, and the Subsidy Roll for 1646 shows that at that date two
large residences existed side by side,[471] although of course these may
have been only portions of one very large house.
As early as 1664 the house (or houses) seems to have been
split up among a number of occupants. The entries in the Hearth Tax
Rolls for 1664–1674 in respect of this portion of the street (amending
the wrong order of the first roll) are as follows. The numbers in
brackets represent the number of hearths taxed.
1665. 1666.
Sam Nelson (6) Samuel Nelson (6)
Lord Baltimore (15) Cecill, Lord Baltimore (15)
Lord Marquess of Winchester in 2 houses
Lady Spencer (16)
(30)[472]
A. Gilbt. Crouch, Esq. (7) Widow Tattershall (6)
B. John Wolstenholm (14) John Wolstenholme, Esq. (14)
C. Humph. Wild, Esq. (14)
The Portugall Embassador’s E (20)
House.
D. Humph. Wild, Esq. (16) Humfrey Weild, Esq. (16)
E. Countess of Exeter (9) E (10)
F. Mary Sanders (9) Mrs. Mary Sanders (9)
G. John Worsley (3) John Worsley, Marcht of Intercost (6)

1673. 1675.
Samuel Nelson (6) Samuel Nelson (6)
Lord Baltimore (15) The Lady Baltimore (15)
Marquess of Winchester (3) Marquess of Winchester (30)
A. Thomas Hawker[473] (7) Thomas Hawker (7)
B. Mary James (13) E (13)
C. The French Embassadour
Spanish Ambassador (20)
(20)
D. Humphrey Wild, Esq. (16) Humphrey Wild, Esq. (16)
E. Thomas Weedon, Esq. (5) Madd. James (5)
F. Mary Saunders (9) Mary Saunders (9)
Mary Watson (1) Mrs. Watson (1)
G. John Worseley (6) John Worsley (6)

Of these neither (A)[473] nor (G)[474] formed part of Weld


House, and (B) is doubtful. (C) and (F) however, certainly did, the
former being the ambassadorial residence (see below) and the latter
being mentioned in a deed of 1673, quoted by Parton[475], as “the
wing of the said great house, late in Mary Saunders’s possession.”
The house was therefore at this time in at least four distinct
occupations.[476]
The two chief residences thus formed were evidently the
house occupied by Weld himself and the ambassadorial house,
immediately adjoining on the south. The former was the scene of a
wild riot in 1671, when, Humphrey Weld having attempted to arrest
the ringleaders in a tumult close by, the rabble, in a fury, attacked his
house.[477]
The Portuguese Ambassador seems to have taken up his
residence at Weld House in 1659, for on 9th July in that year he
(Francisco de Mello) wrote from “Wild Street” to William Lenthall,
announcing the arrival of his credentials, and asking for an audience.
[478]
The extracts from the Hearth Tax Rolls given above show that he
was still there in 1665, gone in 1666, that the French Ambassador
was there in 1673,[479] and the Spanish Ambassador in 1675.
Numerous references to the residence of the last mentioned occur.
[480]
On the flight of James II. in December, 1688, the mob sacked the
ambassador’s house.
Shortly afterwards Weld House and the ground belonging to it
were purchased by Isaac Foxcroft, who let out the property on
building lease.[481] The house, or a portion of it, was however, still
standing in 1694.[482]
In the Council’s Collection is:—
North-east side of Great Wild Street, in 1906, looking south-east
(photograph).
XLII.–XLIII.—Nos. 6 and 7, WILD COURT.

The Society for the Improvement of the Condition of the


Labouring Classes are the ground landlords of these houses.
The only objects of interest which the premises contain are
four 18th-century hob grates, illustrated below.
The Council’s collection contains:—
[483]Four cast-iron hob grates (measured drawing).

You might also like