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

Data structure and algorithm analysis C language English 2 Adapted China Edition Mark Allen Weiss - The latest ebook edition with all chapters is now available

The document provides information about the book 'Data Structures and Algorithm Analysis in C' by Mark Allen Weiss, including a link for downloading the full version and details on its adaptation for Chinese students. It highlights the book's focus on algorithm analysis, data structures, and programming efficiency, suitable for advanced data structures courses or graduate studies. Additionally, it mentions other related ebooks available for download on the same website.

Uploaded by

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

Data structure and algorithm analysis C language English 2 Adapted China Edition Mark Allen Weiss - The latest ebook edition with all chapters is now available

The document provides information about the book 'Data Structures and Algorithm Analysis in C' by Mark Allen Weiss, including a link for downloading the full version and details on its adaptation for Chinese students. It highlights the book's focus on algorithm analysis, data structures, and programming efficiency, suitable for advanced data structures courses or graduate studies. Additionally, it mentions other related ebooks available for download on the same website.

Uploaded by

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

Visit https://ebookultra.

com to download the full version and


explore more ebooks or textbooks

Data structure and algorithm analysis C language


English 2 Adapted China Edition Mark Allen Weiss

_____ Click the link below to download _____


https://ebookultra.com/download/data-structure-and-
algorithm-analysis-c-language-english-2-adapted-china-
edition-mark-allen-weiss/

Explore and download more ebooks or textbooks at ebookultra.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Data Structures And Problem Solving Using C 2nd


International Edition Edition Mark Allen Weiss

https://ebookultra.com/download/data-structures-and-problem-solving-
using-c-2nd-international-edition-edition-mark-allen-weiss/

Data structures and algorithm analysis in C Fourth


Edition, International Edition / Chandavarkar

https://ebookultra.com/download/data-structures-and-algorithm-
analysis-in-c-fourth-edition-international-edition-chandavarkar/

Data Structures and Algorithm Analysis in C 3rd Edition


Dr. Clifford A. Shaffer

https://ebookultra.com/download/data-structures-and-algorithm-
analysis-in-c-3rd-edition-dr-clifford-a-shaffer/

Mental States Volume 2 Language and cognitive structure


Studies in Language Companion Series 93rd Edition Andrea
C. Schalley
https://ebookultra.com/download/mental-states-volume-2-language-and-
cognitive-structure-studies-in-language-companion-series-93rd-edition-
andrea-c-schalley/
Discovering Language The Structure of Modern English 1st
Edition Lesley Jeffries

https://ebookultra.com/download/discovering-language-the-structure-of-
modern-english-1st-edition-lesley-jeffries/

Data Analysis and Applications 2 1st edition Edition


Bozeman

https://ebookultra.com/download/data-analysis-and-applications-2-1st-
edition-edition-bozeman/

Andrea Zanzotto The Language of Beauty s Apprentice


Beverly C. Allen

https://ebookultra.com/download/andrea-zanzotto-the-language-of-
beauty-s-apprentice-beverly-c-allen/

Data Structures and Algorithm Analysis in Java ■■■■■■■■■


Java■■■■ ■■■■■■■■■ Weiss

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

Techniques of Saxophone Playing English and German Edition


Marcus Weiss

https://ebookultra.com/download/techniques-of-saxophone-playing-
english-and-german-edition-marcus-weiss/
Data structure and algorithm analysis C language English
2 Adapted China Edition Mark Allen Weiss Digital
Instant Download
Author(s): Mark Allen Weiss
ISBN(s): 9787115139849, 7115139849
Edition: 2
File Details: PDF, 20.07 MB
Year: 2005
Language: english
. ‘Ta
I P w
A
‘4’ III
..

.— V V

Data Structures

arid

Algorithm AnaIVsIs In C

Mark Allen Weiss


e.

9::
=

4
I. . : I.

- in: •1

= : .... I•
I-

II

S.

-- t

:4l_ S : ::Er

I I I

=tfl*
I I 11 I I I -——•—ll
I I .1

ISBN 7—115—13984—9 I I I I I I I I I I I I 1 I •I

lg_ •.59

ISW7-1 15-13984-9/’1P4957

‘iLfft:49.(K) )L
9 787115 139849 >

-
TURING;0]

Data Structures and Algorithm Analysis in C

(Second Edition)

..L+I- ‘-1
I,-, h:i

(3&•2&)
[] Mark Allen Weiss

POSTS & TELECOM PRESS;1]


J4fl (CIP)
flitTr: C1WftMiR: 2/ () flh? (Weiss,M.A.) *.
h)t: )P.Wñ&± 2005.8

(QWJ&. itfltJLWi)

ISBN 7-115-13984-9

1. t II. ft.. III. ©M-&t ©flY-tft-t ®c -WtE-


t IV. TP3I1.12

N*R14SfficiPflt (2005) M092227

t1-fl43J
iFIIMiA! (t1t&
4&***Ji—C 2 }&)

[] Mark Allen Weiss

A B&4±+1J!i&t ,tihlflV9iWfll 14 4
WIS 100061 k !pgilt 315ptpress com.cn

l lit hltp://www.ptpress.com.cn

njAt1 uDJrpAi
1gj1rj ,jffi2ffi
)F4-: 800x1000 1/16

141*: 32.5

: 7271$ 2005W8Jj3W1&

EPi: 1—30003W 2005W SJIt$3W I Ep41J

a4Tu 01-2005-3578 -
ISBN 7-115-13984-9/TP 4957

ffr 49.OO5L
jNR*)M: (010)88593802 P MM: (010)67129223
Adapter’s Foreword

Purpose
The original of this book is an excellent work of Mark Allen Weiss. All the
fundamental topics are covered. The ADT concepts and the analysis of the
algorithms (especially the average analysis)
case emphasized. The extensive
are

are also quite helpful to the students.


examples
Till now the original book has been introduced to Chinese students for two

years and has received positive


feedbacks from many instructors and students. This

re-composition is made to trim the contents of the book so that it better fits a

second-year undergraduate course in data structures and algoritlun analysis for the
Chinese students.

What’sNew
The recomposition includes two major changes. First, the review section
structure

of mathematics has been canceled since sophomore students in China have taken
sufficient courses in mathematics in their first-year study, including calculus, linear
algebra, and discrete mathematics. Secondly, the original Chapter 5 is moved to
follow Chapter 7, in order to show hashing as a method to break the lower bound
of searching by comparisons only.
Other minor changes include adding some interesting data structures and
methods, and rearranging part of the contents. Introduction of the sparse matrix
representation is added as an example of application of mu.ltilists in Section 3.2.
At the mean time, bucket sort and radix sort are discussed in more details in

Chapter 6 (which Chapter 7 in the original book) instead of being given as an


was

example in Section 3.2. In Chapter 4, the two sections about tree traversals, namely
Sections 4.1.2 and 4.6, are merged into one and are inserted into Section 4.2.3.
Threaded binary tree is then formally introduced instead of being mentioned in
exercises only. At the beginning of Chapter 7 (which was Chapter 5 in the original

book), Hashing, a method called interpolation search is briefly discussed to make


the point that it is possible to break the lower bound if we search by methods other
than comparisons. Finally in Section 6.8, Sorting Large Structures, we introduce
table sort as a method to handle the case in which physically sorting large structures
is required.
Adapter’s Foreword

Acknowledgments
We feel grateful to Mark Allen Weiss, the author of the original book, and Pearson
Education, the original publisher, for their great support on this recomposition. It is
their understanding and generosity that make it possible for more Chinese students to

enjoy thisdistinguished book.


Thanks to all the
colleagues and students who have communicated with me regarding
to their impressions of the original book. Special thanks go to Professor Qinming He,

for his helpful feedbacks and suggestions.

Finally I would like to thank everyone at Turing Book Company, the publisher of
this adapted edition, who have put in great effort to make this kind of cooperation
possible.
It is my very first attempt on making a recomposition of a textbook. If you have

any suggestions for improvements, I would very much appreciate your comments.

Yue Chen
chenyuecs.zju.edu.cn
Zhejiang University
PREFACE

Purpose/Goals
This book describes data structures, methods of organizing large amounts of data,
and algorithm analysis, the estimation of the running time of algorithms. As computers

become faster and faster, the need for programs that canhandle large amounts
of input becomes more acute. Paradoxically, this requires more careful attention to

efficiency, since inefficiencies in programs become most obvious when input sizes are
large. By analyzing an algorithm before it is actually coded, students can decide if a
particular solution will be feasible. For example, in this text students look at specific
problems and see how careful implementations can reduce the time constraint for
large amounts of data from 16 years to less than a second. Therefore, no algorithm
or data structure is presented without an explanation of its running time. In some

cases, minute details that affect the running time of the implementation are explored.

Once a solution method is determined, a program must still be written. As


computers have become more powerful, the problems they must solve have become
larger and more complex, requiring development of more intricate programs. The
goal of this text is to teach students good programming and algorithm analysis skills
simultaneously so that they can develop such programs with the maximum amount
of efficiency.
This book is suitable for either an advanced data structures (CS7) course or
a first-year graduate course in algorithm analysis. Students should have some knowledge

of intermediate programming, including such topics as pointers and recursion,


and some background in discrete math.

Approach
I believe it is important for students to learn how to program for themselves, not

how to copy programs frombook. On the other hand, it is virtually impossible to


a

discuss realistic programming issues without including sample code. For this reason,
the book usually provides about one-half to three-quarters of an implementation,
and the student is encouraged to supply the rest. Chapter 12, which is new to this
edition, discusses additional data structures with an emphasis on implementation
details.
PREFACE

The algorithms in this book arepresented in ANSI C, which, despite some


flaws, is arguably the most popular systems programming language. The use of C
instead of Pascal allows the use of dynamically allocated arrays (see, for instance,
rehashing in Chapter 7). It also produces simplified code in several places, usually
because the and (&&) operation is short-circuited.
Most criticisms of C center on the fact that it is easy to write code that is barely
readable. Some of the more standard tricks, such as the simultaneous assignment
and testing against 0 via

if (x=y)

are generally used in the text, since the loss of clarity is compensated by only a
not

few keystrokes and no increased speed. I believe that this book demonstrates that
unreadable code can be ivoided by exercising reasonable care.

Overview

Chapter 1 contains review material on recursion. I believe the only way to be


comfortable with recursion is to see good uses over and over. Therefore, recursion
is prevalent in this text, with examples in every chapter except Chapter 7.
Chapter 2 deals with algorithm analysis. This chapter explains asymptotic analysis
and its major weaknesses. Many examples are provided, including an in-depth
explanation of logarithmic running time. Simple recursive programs are analyzed
by intuitively converting them into iterative programs. More complicated divide-
and-conquer programs are introduced, but some of the analysis (solving recurrence
relations) is implicitly delayed until Chapter 6, where it is performed in detail.
Chapter 3 covers lists, stacks, and queues. The emphasis here is on coding
these data structures using ADT5, fast implementation of these data structures, and
an
exposition of some of their uses. There are almost no programs (just routines),
but the exercises contain plenty of ideas for programming assignments.
Chapter 4 covers trees, with an emphasis on search trees, including external
search trees (B-trees). The uix file system and expression trees are used as examples.
AVE treesand splay trees are introduced but not analyzed. Seventy-five percent of the
code is written, leaving similar cases to be completed by the student. More careful
treatment of search tree implementation details is found in Chapter 12. Additional
coverage of trees, such as file compression and game trees, is deferred until Chapter
10. Data structures for an external medium are considered as the final topic in
several chapters.

Chapter 5 is about priority queues. Binary heaps are covered, and there is
additional material on of the theoretically interesting implementations of
some

priority queues. The Fibonacci heap is discussed in Chapter 11, and the pairing heap
is discussed in Chapter 12.
PREFACE lx

Chapter 6 covers sorting. It is very specific with respect to coding details and
and
analysis. All the important general-purpose sorting algorithms are covered
are analyzed in detail: insertion sort, Shellsort, heapsort,
compared. Four algorithms
and quicksort. The analysis of the average-case running time of heapsort is new to
this edition. External sorting is covered at the end of the chapter.
hash tables. Some analysis is
Chapter 7 is a relatively short chapter concerning
at the end of the chapter.
performed, and extendible hashing is covered
Chapter 8 discusses the disjoint set algorithm with proof of the running time.
This is a short and specific chapter that can be skipped if Kruskal’s algorithm is not
discussed.
Chapter 9 covers graph algorithms. Algorithms on graphs are interesting, not
only because they frequently occur in practice but also because their running time is
so heavily dependent on the proper use of data structures. Virtually all of the standard

algorithms are presented along with appropriate data structures, pseudocode, and
analysis of running time. To place these problems in a proper context, a short
discussion on complexity theory (including NP-completeness and undecidability) is
provided.
Chapter 10 covers algorithm design by examining common problem-solving
techniques. This chapter is heavily fortified with examples. Pseudocode is used in
these later chapters so that the student’s appreciation of an example algorithm is not
obscured by implementation details.
Chapter 11 deals with amortized analysis. Three data from Chapters
structures

4 and 5 and the Fibonacci heap, introduced in this analyzed.


chapter, are

Chapter 12 is new to this edition. It covers search tree algorithms, the k-d tree,
and the pairing heap. This chapter departs from the rest of the text by providing
complete and careful implementations for the search trees and pairing heap. The
material is structured so that the instructor can integrate sections into discussions
from other chapters. For example, the top-down red black tree in Chapter 12 can
be discussed under AVL trees (in Chapter 4).

Chapters 1—9
provide enough material for most one-semester data structures
courses. If time permits, then Chapter 10 be covered. A graduate course
can

on algorithm analysis could cover Chapters 6—11.


The advanced data structures
analyzed in Chapter 11 can easily be referred to in the earlier chapters. The
discussion of NP-completeness in Chapter 9 is far too brief to be used in such a
course. Garey and Johnson’s book on NP-completeness can be used to augment this

text.

Exercises

Exercises, provided at the end of each chapter, match the order in which material
is presented. The last exercises may address the chapter as a whole rather than a
specific section. Difficult exercises are marked with an asterisk, and more challenging
exercises have two asterisks.
PREFACE

References

References are placed at the end of each chapter. Generally the references either
are historical, representing the original of the material, or they represent
source

extensions and improvements to the results given in the text. Some references
represent solutions to exercises.

Code Availability
The example program code in this book is available via anonymous ftp
at ftp://ftp.csfiu.edu/pub/weiss/WEISS_2E.tar.Z

Acknowledgments
Many, many people have helped me in the preparation of books in this series. Some
are listed in other versions of the book; thanks to all.
For this edition, I would like to thank my editors at Addison-Wesley, Carter
Shanklin and Susan Hartman. Ten Hyde did another wonderful job with the
production, and Matthew Harris and his staff at Publication Services did their usual
fine work putting the final pieces together.

M.A.W.

Miami, Florida
July, 1996
CONTENTS

Adapter’s Foreword
Preface

Introduction 1
1.1. What’s the Book About? 1

1.2. A Brief Introduction to Recursion 3

Summary 7
Exercises 7
References 8

2 Algorithm Analysis 9

2.1. Mathematical Background 9


2.2. Model 12
2.3. WhattoAnalyze 12
2.4. Running Time Calculations 14
2.4.1. ASimpleExainple 15
2.4.2. General Rules 15
2.4.3. Solutions for the Maximum Subsequence Sum Problem 18
2.4.4. Logarithms Running Time
in the 22
2.4.5. Checking Your Analysis 27
2.4.6. AGrainofSait 27
Summary 28
Exercises 29
References 33

xi
CONTENTS

3 lists, Stacks, and Queues 35


3.1. Abstract Data Types (AWT5) 35

3.2. TheLisLwT 36
3.2.1. Simple Array Implementation of Lists 37
3.2.2. Linked Lists 37
3.2.3. Programming Details 38
3.2.4. Common Errors 43
3.2.5. DoublyLinked Lists 45
3.2.6. Circularly Linked Lists 46
3.2.7. Examples 46
3.2.8. Cursor Implementation of Linked Lists 50
3.3. The StackAnT 56
3.3.1. stack Model 56
3.3.2. Implementation of Stacks 57
3.3.3. Applications 65
3.4. The QueueMT 73
3.4.1. Queue Model 73
3.4.2. Array Implementation of Queues 73
3.4.3. Applications of Queues 78

Summary 79
Exercises 79

4 Trees 83
4.1. Preliminaries 83
4.1.1. Terminology 83
4.1.2. TreeThtversalswithanApplication 84
4.2. Binary Trees 85
4.2.1. Implementation 86
4.2.2. Expression Trees 87
4.2.3. Tree Traversals 90

4.3. The Search Tree Search Trees


APT—Binary 97
4.3.1. MakeEmpty 97
4.3.2. Find 97
4.3.3. FindMin and FindMax 99
4.3.4. Insert 100
4.3.5. Delete 101
4.3.6. Average-Case Analysis 103
4.4. AVL Trees 106
4.4.1. single Rotation 108
4.4.2. Double Rotation 111
CONTENTS

4.5. Splay Trees 119


4.5.1. A Simple Idea (That Does Not Work) 120
4.5.2. Splaying 122

4.6. B-Trees 128

Summary 133
Exercises 134
References 141

5 Priority Queues (Heaps) 145


5.1. Model 145
5.2. Simple Implementations 146
5.3. Binary Heap 147
5.3.1. Structure Property 147
5.3.2. Heap Order Property 148
5.3.3. Basic Heap Operations 150
5.3.4. Other Heap Operations 154
5.4. Applications of Priority Queues 157
5.4.1. The Selection Problem 157
5.4.2. Event Simulation 159
5.5. d-Heaps 160
5.6. Leftist Heaps 161
5.6.1. LeftistHeapProperty 161
5.6.2. Leftist Heap Operations 162
5.7. Skew Heaps 168
5.8. Binomial Queues 170
5.8.1. Binomial Queue Structure 170
5.8.2. Binomial
Queue Operations 172
5.8.3. Implementation of Binomial Queues 173
Summary 180
Exercises 180
References 184

6 Sorting 187
6.1. Preliminaries 187
6.2. Insertion Sort 188
-

6.2.1. TheAlgorithm 188


6.2.2. AnalysisofinsertionSort 189
CONTENTS

6.3. A Lower Bound for Simple Sorting Algorithms 189


6.4. Sheilsort 190
6.4.1. Worst-Case Analysis of Shellsort 192
6.5. Heapsort 194
6.5.1. Analysis of Heapsort 196
6.6. Mergesort 198
6.6.1. Analysis of Mergesort 200
6.7. Quicksort 203
6.7.1. PickingthePivot 204
6.7.2. Partitioning Strategy 205
6.7.3. SmallArrays 208

6.7.4. Actual Quicksort Routines 208

6.7.5. Analysis of Quicksort 209


6.7.6. A Linear-Expected-Time Algorithm for Selection 213
6.8. Sorting Large Structures 215
6.9. A General Lower Bound for Sorting 216
6.9.1. Decision Trees 217

6.10. Bucket Sort and Radix Sort 219


6.11. External Sorting 222
6.11.1. WhyWe Need NewAlgorithms 222
6.11.2. ModelforExternalSorting 222

6.11.3. TheSimpleAlgorithm 222


6.11.4. MultiwayMerge 224
6.11.5. PoLyphaseMerge 225
6.11.6. Replacement Selection 226
Summary 227
Exercises 229
References 232

7 Hashing 235
7.1. General Idea 235
7.2. Hash Function 237
7.3. Separate Chaining 239
7.4. Open Addressing 244
7.4.1. Linear Probing 244
7.4.2. Quadratic Probing 247
7.4.3. Double Hashing 251
CONTENTS XV

7.5. Rehashing 252


7.6. Extendible Hashing 255
Summary 258
Exercises 259
References 262

8 The Disjoint Set APT 265


8.1. Equivalence Relations 265
8.2. The Dynamic Equivalence Problem 266
8.3. Basic Data Structure 267
8.4. Smart Union Algorithms 271
8.5. Path Compression 273
8.6. Worst Case for Union-by-Rank and Path Compression 275
8.6.1, Analysis of the Union/Find Algorithm 275
8.7. An Application 281
Summary 281
Exercises 282
References 283

9 Graph Algorithms 285

9.1. Definitions 285


9.1.1. Representation of Graphs 286
9.2. Topological Sort 288

9.3. Shortest-Path Algorithms 292


9.3.1. Unweighted Shortest Paths 293
9.3.2. Dijkstra’s Algorithm 297
9.3.3. Graphs with Negative Edge Costs 306
9.3.4. Acycic Graphs 307
9.3.5. All-Pairs Shortest Path 310
9.4. Network Flow Problems 310
9.4.1. A Simple Maximum-Flow Algorithm 311
9.5. Minimum Spanning Tree 315
9.5.1. Prim’s Algorithm 316
9.5.2. Kruskal’s Algorithm 318
CONTEMS

9.6. Applications of Depth-First Search 321


9.6.1. Undirected Graphs 322
9.6.2. Biconnectlvity 324
9.6.3. Euler Circuits 328
9.6.4. Directed Graphs 331
9.6.5. Finding Strong Components 333

9.7. Introduction to NP-Completeness 334


9.7.1. Easyvs.Hard 335
9.7.2. The ClassNP 336
9.7.3. NP-Complete Problems 337

Summary 339
Exercises 339
References 345

10 Algorithm Design Techniques 349


10.1. GreedyAlgorithms 349
10.1.1. ASimpleSchedulingProblem 350
10.1.2. Huffinan Codes 353
10.1.3. ApproximateBinPacking 359

10.2. Divide and Conquer 367


10.2.1. Running Time of Divide and Conquer Algorithms 368
10.2.2. Closest-Points Problem 370
10.2.3. The Selection Problem 375
10.2.4. Theoretical Improvements for Arithmetic Problems 378

10.3. Dynamic Programming 382


10.3.1. Using a Table Instead of Recursion 382
10.3.2. Ordering Matrix Multiplications 385
10.3.3. OptimalBinarySearchTree 389
10.3.4. All-Pairs Shortest Path 392

10.4. Randomized Algorithms 394


10.4.1. Random Number Generators 396
10.4.2. Skip Lists 399
10.4.3. Primality Testing 401

10.5. Backtracking Algorithms 403


10.5.1. The Turnpike Reconstruction Problem 405
10.5.2. Gaines 407

Summary 415
Exercises 417
References 424
CONTEWFS xvii

11 Amortized Analysis 429


11.1. AnUnrelatedPuzzle 430

11.2. Binomial Queues 430

11.3. Skewlleaps 435


fl.4. Fibonacci Heaps 437
11.41. Cuffing Nodes in Leftist Heaps 430
11.4.2. Lazy Merging for Binomial Queues 441
11.4.3. The Fibonacci Heap Operations 444
11.4.4. Proof of the Tune Bound 445
11.5. SplayTrees 447
Summary 451
Exercises 452
References 453

12 Advanced Data Structures and ImplementatIon 455


12.1. Top-Down SplayTrees 455
12.2. Red Black Trees 459
12.2.1. Bottom-Up Insertion 464
12.2.2. Top-Down Red BlackTrees 465
12.2.3. Top-Down Deletion 467

12.3. Deterministic Skip Lists 471

12.4. AA-Trees 478

12.5. Treaps 484


12.6. k-dTrees 487
12.7. Pairing Heaps 490
Summary 496
Exercises 497
References 499
CHAPTER 1

Introduction

In thischapter, we discuss the aims and goals of this text and briefly review

programming concepts. We will


See that how a program performs for reasonably large input is just as important
as its performance on moderate amounts of input.

Briefly review recursion.

1.1. What’sthe Book About?

Suppose you have a group of N numbers and would like to determine the kit largest.
This is known as the selection problem. Most students who have had a programming
course or two would have no difficulty writing a
program to solve this problem.

There are quite a few “obvious”


solutions.
One way to solve this problem would be to read the N numbers into an array,

sort the array in decreasing order by some simple algorithm such as bubblesort, and
then return the element in position k.
A somewhat better algorithm might be to read the first k elements into an array
and sort them (in decreasing order). Next, each remaining element is read one by
one. As a element arrives, it is ignored if it is smaller than the kit element
new

in the array. Otherwise, it is placed in its correct spot in the array, bumping one
element of the array. When the algorithm ends, the element in the kth position
out

is returned as the answer.


Both algorithms are simple to code, and you are encouraged to do so. The

natural questions, then, which algorithm is better and, more important, is either
are

algorithm good enough? A simulation using a random file of 1 million elements


and k =
500,000 will show that neither algorithm finishes in a reasonable amount
of time; each requires several days of computer processing to terminate (albeit
CHAPThR 1/INTRODUCTION

eventually with a correct answer). An alternative method, discussed in Chapter 6,


gives a solution in about a second. Thus, although our
proposed algorithms work,
they cannot beconsidered good algorithms, because they are entirely impractical for
sizes that a third algorithm can handle in a reasonable amount of time.
input
A second problem is to solve a popular word puzzle. The input consists of a
two-dimensional array of letters and a list of words. The object is to find the words
in thepuzzle. These words may be horizontal, vertical, or diagonal in any direction.
As example, the puzzle shown in Figure 1.1 contains the words this, two, fat,
an

and that. The word this begins at row 1, column 1, or (1,1), and extends to (1,4);
two goes from (1,1) to (3,1); fat goes from (4,1) to (2,3); and that goes from (4,4)
to (1,1).
Again, there are at least two straightfonvard algorithms that solve the problem.
For each word in the word list, we check each ordered triple (row, column,
orientation) for the presence of the word. This amounts to lots of nested for loops
but is basically straightforward.
Alternatively, for each ordered quadruple (row, column, orientation, number
of characters) that doesn’t run off an end of the puzzle, we can test whether the
word indicated is in the word list. Again, this amounts to lots of nested for loops. It

is possible to save some time if the maximum number of characters in any word is
known.
It is relatively easy to code up either method of solution and solve many of the
real-life puzzles commonly published in magazines. These typically have 16 rows, 16
columns, and 40 or so words. Suppose, however, we consider the variation where
only the puzzle board is given and the word list is essentially an English dictionary.
Both of the solutions proposed require considerable time to solve this problem and
therefore are not acceptable. However, it is possible, even with a large word list, to
solve the problem in a matter of seconds.
An important concept is that, in many problems, writing a working program is
not good enough. If the program is to be runon a large data set, then the running

time becomes an issue. Throughout this book we will see how to estimate the

running time of a program for large inputs and, more important, how to compare
the running times of two programs without actually coding them. We will see
techniques for drastically improving the speed of a program and for determining
program bottlenecks. These techniques will enable us to find the section of the code
on which to concentrate our
optimization efforts.

Figure 1.1 Sample word puzzle

1 2 3 4

1 t Ii 1 s

2 w a t s

3 o a h g
4 f g d t
1.2. A BRIEF INTRODUCTION TO RECURSION 3

1.2. A Brief Introduction to Recursion

Most mathematical functions that we arefamiliar with are described by a simple


formula. For instance, we can convert temperatures from Fahrenheit to Celsius by
applying the formula

C =
S(F 32)19
Given this formula, it is trivial to write a C function; with declarations and braces
removed, the one-line formula translates to one line of C.
Mathematical functions are sometimes defined in a less standard form. As an
example, we can define a function F, valid on nonnegative integers, that satisfies
F(O) 0 and F(X)
=
2F(X 1) + V. From this definition we see that F(1)
=
1, =

F(2) =
6, F(3) =
21, and F(4) =
58. A function that is defined in terms of itself
is called recursive. C allows functions to be recursive.* It is important to remember
that what C provides is merely an attempt to follow the recursive spirit. Not all
mathematically recursive functions are efficiently (or correctly) implemented by
C’s simulation of recursion. The idea is that the recursive function F ought to be
expressible in only a few lines, just like a nonrecursive function. Figure 1.2 shows
the recursive implementation of F.
Lines I and 2 handle what is known as the base case, that is, the value for
which the function is directly known without resorting to recursion. Just as declaring
F(X) 2F(X
=
1) + X2 is meaningless, mathematically, without including the fact
that F(0) 0, the recursive C function doesn’t make sense without a base case.
=

Line 3 makes the recursive call.

There are several important and possibly confusing points about recursion. A
common question is: Isn’tthis just circular logic? The answer is that although we are
a function in terms of itself, we are not defining a
defining particular instance of the
function in terms of itself. In other words, evaluating F(S) by computing F(S) would
be circular. Evaluating F(S) by computing F(4) is not circular—unless, of course,
F(4) is evaluated by eventually computing F(S). The important two most issues are

probably the how and


why questions. Chapter 3, the how and why
In issues are

formally resolved. We will give an incomplete description here.


It turns out that recursive calls are handled no
differently from any others. If F
is called with the value of 4, then line 3 requires the computation of 2 * F(3) + 4 * 4.
Thus, a call is made to compute F(3). This requires the computation of 2 * F(2) + 3 *
3. Therefore, another call is made to compute F(2). This means that 2 *
F(1) + 2 * 2

must be evaluated. To do so, F(I) is computed as 2 * F(0) + I * I. Now, F(0) must


be evaluated. Since this is a base case, we know a priori that F(O) =
0. This enables
the completion of the calculation for F(l), which is now seen to be 1. Then F(2),

‘Using recursion for numerical calculations is usually a bad idea. We have done so to illustrate the basic
points.
Other documents randomly have
different content
Nälkä, nälkä, nälkä kiihtyy.
Mutta miss' on uhriraukat,
missä polot piillen viihtyy?
Miks' on huolissansa haukat?

Joko — taikka.

Vapisevat vallan pylväät, suur' on hätä sortajoiden, koska


ryntää urhot ylväät vastaan varustusta noiden.

Säälitön on kansa halpa,


kun se kyltyy alennukseen,
raskas on sen kauhukalpa,
kolkuttaissaan onnen ukseen.

Ellei onnen ovi aukee, ellei mielivalta vaivu, silloin muurit


maahan raukee, kansa kun ei enää taivu.

He nauravat uhkaa.

He nauravat uhkaa, eivät käskyä kuule ja rangaistuksesta


veisaavat viisi.

Kun he hurjistuivat, niin hurjistuivat ja nälkä vei "järjen"


päästä.

Mitä leivättömälle on laki?


Orja kunnioitti lakia ja ahkeroi työssä.
Vaan henkensä häilyi epätoivon yössä
ja ruumiinsa kärsi ja kitui.

Hän epäillä alkoi, ei uskonut enää ja sitten seurasi rikos.

Ja rikosta seuraa rikosten sarja.

Mut rankaisu on vaan oikeuden pilkkaa ja mielettömyyttä,


pääsyypäitä kun se ei kohtaa.

"Nöyrry!"

On orjan nahka parkittu ja tunto häll' on puuta, hän sietää


paljo iskuja ja hävytöntä suuta.

Kun laiska lortus, kiskuri


hänt' ahdistaa kuin hiisi
ja raatajansa rauhasta
hän välittäikse viisi

ja, apunansa käyttäen aseensa likaisimmat, hän orjan


päälle vierittää kaikk' katalimmat vimmat;

ja työn kun kaikki tulokset hän raatajalt' on vienyt, niin että


putipuhdas tää jo vihoviimein lie nyt;

ja kosk' on uhri uupunut ja kuolemaan hän käypi, niin pappi


prameudessaan luo polon ennättäypi
ja synninpäästön hälle suo ja kehottaa: sa köyrry ja käännä
katsees luojan luo, oi onneton, ja — nöyrry!

"Langennut".

On orjan merkki otsassaan, vaan synkät silmät palaa, kuin


vapaan hengen konsanaan, ja uhman tulta valaa.

On häntä lyöty lyömistään


ja yhä lyödään syyttä,
hän osaksensa yhtenään
saa sydämettömyyttä.

Se sama pyhä maailma,


mi hänet työnsi lokaan,
se sydämeensä armotta
"palkaksi" pisti okaan.

Hän "langennut", hän portto on, vaan siitä hän ei hän


vastaa. Muut hälle loivat kohtalon, hän elää ainoastaan.

Herahti kyynel.

Pikkutyttönen, pikkutyttönen,
herahti kyynel silmähän sulle.
Arvasin sen:
elämä raskas on myöskin mulle.
Köyhä olet, onneton, pikkutyttönen,
kerjäten etsit sa onnea turhaan,
väsähtäen.
Riistäjä rintasi riemut murhaa.

Ilman lempeä, vailla hoivaa poljet sa puutteen polkua


loivaa, niinkuin kulkevat tuhannet toiset elämän murjomat
murheen loiset kuoleman kammioihin.

Miksikä?

"Nuorassa hirttäyneen taloss' ei saa leikkiä lyödä,


maassa makaavaa ei herjata kenkään saa!"

Miksikä riistäjät siis yhä kansaa solvaa ja sättii


sitte kun säälittä sen löivät he maan tasahan?

Sääli teitä.

Sääli teitä raukat, joilla lainkaan mieltä ei, ei päätä. Käytte


elon aukeoilla aina pahan ilman säätä.

Ratki suurin suin ja leuvoin


kenopäin te taivallatte,
muita ohjain narrin neuvoin
itsenne te unhotatte.
Sääli teitä, sääli teitä:
Seinään pää! on huono ohja.
Ollaan vaikka enkeleitä,
niin ei haittaa alla pohja.

Pilli soimaan.

Pilli soimaan ja polkkaa tanssimahan tuo kankea karhu:


kansa. Tovin olkoon kytkyintä vailla hän nyt: taas sitte on
yllänsä ansa.

Pilli soimaan. Siis käy karkelohon


kera kahlijas, köntys, kansa;
huvin maksaa mahtajat ympäri maan,
sinä vain olet vierahanansa.

Pilli soimaan. Pois viha viidakkohon ja rakkaita olkaamme —


tiima. Sen jälkeen rauhassa viuhukohon taas riistäjän
ruoskansiima.

Tuhka tanssii.

Tuhka tanssii tuulen myötä sinne tänne, sinne tänne. Aika


haastaa: työtä, työtä, muuten ehtyy elämänne!

Valitellaan, vaikeroidaan
mielipuolin puuskin, raivoin,
tositoimiss' olla voidaan
käsin vankoin, vaan ei aivoin.

Ja on totuus karvas niellä, valhe kaunis, petos hauska.


Mutta matkaa elontiellä moni mennyt ihmisrauska.

Miks ihmetellään —?

Miks ihmetellään, että on ankara elämän laki, kun ensin on


rikottu sen joka käskyä vastaan?

Ja synnit ovat surkean suuret: kuin hullut toukomiehet


rikkojat käyvät ja heittävät elämän siemenet hukkaan ja
polkevat päälle ja kylvävät kuoloa elämän peltoon.

Ja kymmenissä kiroissa eellehen käydään ja ihmetellään,


että on ankara elämän laki.
*** END OF THE PROJECT GUTENBERG EBOOK MURROKSESSA ***

Updated editions will replace the previous one—the old editions will
be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying
copyright royalties. Special rules, set forth in the General Terms of
Use part of this license, apply to copying and distributing Project
Gutenberg™ electronic works to protect the PROJECT GUTENBERG™
concept and trademark. Project Gutenberg is a registered trademark,
and may not be used if you charge for an eBook, except by following
the terms of the trademark license, including paying royalties for use
of the Project Gutenberg trademark. If you do not charge anything
for copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund
from the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law
in the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name associated
with the work. You can easily comply with the terms of this
agreement by keeping this work in the same format with its attached
full Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears,
or with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning
of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the Project
Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for


the “Right of Replacement or Refund” described in paragraph 1.F.3,
the Project Gutenberg Literary Archive Foundation, the owner of the
Project Gutenberg™ trademark, and any other party distributing a
Project Gutenberg™ electronic work under this agreement, disclaim
all liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR
NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR
BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK
OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL
NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF
YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving
it, you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or
entity that provided you with the defective work may elect to provide
a replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,


the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many
small donations ($1 to $5,000) are particularly important to
maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.
Project Gutenberg™ eBooks are often created from several printed
editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

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

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookultra.com

You might also like