CSCE 629 Homework 4
June 23, 2010
Homework 4 is due Friday, July 2 in class.
Read chapters 19-21 (omitting 21.4). Turn in the following: 1. Exercise 19.4-1, page 526 2. Problem 19-3(a), page 529 3. Ex
Preface
This book provides a comprehensive introduction to the modern study of computer algorithms. It presents many algorithms and covers them in considerable depth, yet makes their design and analys
Contents
xi
B
Sets, Etc. 1070 B.1 Sets 1070 B.2 Relations 1075 B.3 Functions 1077 B.4 Graphs 1080 B.5 Trees 1085 Counting and Probability 1094 C.1 Counting 1094 C.2 Probability 1100 C.3 Discrete rando
viii
Contents
V Advanced Data Structures
Introduction 18 431 B-Trees 434 18.1 Denition of B-trees 438 18.2 Basic operations on B-trees 441 18.3 Deleting a key from a B-tree 449 Binomial Heaps 455 19.1
Contents
vii
12
Binary Search Trees 253
12.1 What is a binary search tree? 253
12.2 Querying a binary search tree 256
12.3 Insertion and deletion 261
12.4 Randomly built binary search trees 265
13
Red
vi
Contents
II Sorting and Order Statistics
Introduction 6 123
Heapsort 127 6.1 Heaps 127 6.2 Maintaining the heap property 6.3 Building a heap 132 6.4 The heapsort algorithm 135 6.5 Priority queues 1
Contents
Preface
xiii
I Foundations
Introduction 1 3 The Role of Algorithms in Computing 5 1.1 Algorithms 5 1.2 Algorithms as a technology 10 Getting Started 15 2.1 Insertion sort 15 2.2 Analyzing alg
Preface
xv
To the professional The wide range of topics in this book makes it an excellent handbook on algorithms. Because each chapter is relatively self-contained, you can focus in on the topics tha
xiv
Preface
section boundaries marking natural stopping points. In an undergraduate course, you might use only the earlier sections from a chapter; in a graduate course, you might cover the entire cha
xvi
Preface
•
Cliff Stein was added as a coauthor.
•
Errors have been corrected. How many errors? Let’s just say several.
•
There are three new chapters:
•
•
•
•
Chapter 1 discusses the role of algori
CSCE 629 Homework 3
June 16, 2010
Homework 3 is due Wednesday, June 23 in class. Read chapters 15-17. Turn in 1. Problem 15-1, page 404. Suppose that we are given a directed acyclic graph G = (V,E) wi
CSCE 629 Homework 2
June 9, 2010
Homework 2 is due Wednesday, June 16 in class.
Read chapters 13-14. Turn in 1. Exercise 13.3-5, page 322 (Consider a red-black tree formed by inserting n nodes with RB
Preface
xix
Bob Tarjan, and Paul Wang. Several of our colleagues also graciously supplied
us with problems; we particularly thank Andrew Goldberg, Danny Sleator, and
Umesh Vazirani.
It has been a plea
xviii
Preface
Acknowledgments for the rst edition Many friends and colleagues have contributed greatly to the quality of this book. We thank all of you for your help and constructive criticisms. MITs
Preface
xvii
The partitioning method used for quicksort (Section 7.1) and the expected linear-time order-statistic algorithm (Section 9.2) is different. We now use the method developed by Lomuto, whic
Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest Clifford Stein
Introduction to Algorithms
Second Edition
The MIT Press Cambridge, Massachusetts
London, England Dubuque, IA St. Louis Montr al e
1.1 Algorithms
7
Electronic commerce enables goods and services to be negotiated and exchanged electronically. The ability to keep information such as credit card numbers, passwords, and bank statemen
6
Chapter 1 The Role of Algorithms in Computing
have been developed. Which algorithm is best for a given application depends onamong other factorsthe number of items to be sorted, the extent to which
1
The Role of Algorithms in Computing
What are algorithms? Why is the study of algorithms worthwhile? What is the role of algorithms relative to other technologies used in computers? In this chapter,
4
Part I Foundations
Chapter 4 delves further into the divide-and-conquer method introduced in Chapter 2. In particular, Chapter 4 contains methods for solving recurrences, which are useful for descri
Introduction
This part will get you started in thinking about designing and analyzing algorithms. It is intended to be a gentle introduction to how we specify algorithms, some of the design strategies