Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (4 votes)
22 views

Data Structures & Algorithm Analysis in C++ 4th Edition (eBook PDF)instant download

The document provides information on the 4th edition of 'Data Structures & Algorithm Analysis in C++' available for download as an eBook PDF. It includes a comprehensive table of contents covering various topics such as programming, algorithm analysis, data structures, and algorithm design techniques. Additionally, it offers links to other related eBooks and resources.

Uploaded by

balallkamren
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
22 views

Data Structures & Algorithm Analysis in C++ 4th Edition (eBook PDF)instant download

The document provides information on the 4th edition of 'Data Structures & Algorithm Analysis in C++' available for download as an eBook PDF. It includes a comprehensive table of contents covering various topics such as programming, algorithm analysis, data structures, and algorithm design techniques. Additionally, it offers links to other related eBooks and resources.

Uploaded by

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

Data Structures & Algorithm Analysis in C++ 4th

Edition (eBook PDF) download

https://ebooksecure.com/product/data-structures-algorithm-
analysis-in-c-4th-edition-ebook-pdf/

Download more ebook from https://ebooksecure.com


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

Data Structures & Algorithm Analysis in C++ 4th Edition


(eBook PDF)

http://ebooksecure.com/product/data-structures-algorithm-
analysis-in-c-4th-edition-ebook-pdf/

(eBook PDF) Starting Out with Java: From Control


Structures through Data Structures 4th Edition

http://ebooksecure.com/product/ebook-pdf-starting-out-with-java-
from-control-structures-through-data-structures-4th-edition/

Data Structures - eBook PDF

https://ebooksecure.com/download/data-structures-ebook-pdf/

C++ Programming. Program Design including Data


Structures 8th Edition D.S. Malik - eBook PDF

https://ebooksecure.com/download/c-programming-program-design-
including-data-structures-ebook-pdf/
(eBook PDF) Data Structures and Abstractions with Java
4th Edition

http://ebooksecure.com/product/ebook-pdf-data-structures-and-
abstractions-with-java-4th-edition/

(eBook PDF) Data Structures and Abstractions with Java


4th Global Edition

http://ebooksecure.com/product/ebook-pdf-data-structures-and-
abstractions-with-java-4th-global-edition/

(eBook PDF) Data Structures and Other Objects Using


Java 4th Edition

http://ebooksecure.com/product/ebook-pdf-data-structures-and-
other-objects-using-java-4th-edition/

(eBook PDF) Data Structures and Problem Solving Using


Java 4th Edition

http://ebooksecure.com/product/ebook-pdf-data-structures-and-
problem-solving-using-java-4th-edition/

Data Structures & Algorithms in Python 1st Edition John


Canning - eBook PDF

https://ebooksecure.com/download/data-structures-algorithms-in-
python-ebook-pdf-2/
CO NTE NTS

Preface xv

Chapter 1 Programming: A General Overview 1


1.1 What’s This Book About? 1
1.2 Mathematics Review 2
1.2.1 Exponents 3
1.2.2 Logarithms 3
1.2.3 Series 4
1.2.4 Modular Arithmetic 5
1.2.5 The P Word 6
1.3 A Brief Introduction to Recursion 8
1.4 C++ Classes 12
1.4.1 Basic class Syntax 12
1.4.2 Extra Constructor Syntax and Accessors 13
1.4.3 Separation of Interface and Implementation 16
1.4.4 vector and string 19
1.5 C++ Details 21
1.5.1 Pointers 21
1.5.2 Lvalues, Rvalues, and References 23
1.5.3 Parameter Passing 25
1.5.4 Return Passing 27
1.5.5 std::swap and std::move 29
1.5.6 The Big-Five: Destructor, Copy Constructor, Move Constructor, Copy
Assignment operator=, Move Assignment operator= 30
1.5.7 C-style Arrays and Strings 35
1.6 Templates 36
1.6.1 Function Templates 37
1.6.2 Class Templates 38
1.6.3 Object, Comparable, and an Example 39
1.6.4 Function Objects 41
1.6.5 Separate Compilation of Class Templates 44
1.7 Using Matrices 44
1.7.1 The Data Members, Constructor, and Basic Accessors 44
1.7.2 operator[] 45
vii
viii Contents

1.7.3 Big-Five 46
Summary 46
Exercises 46
References 48

Chapter 2 Algorithm Analysis 51


2.1 Mathematical Background 51
2.2 Model 54
2.3 What to Analyze 54
2.4 Running-Time Calculations 57
2.4.1 A Simple Example 58
2.4.2 General Rules 58
2.4.3 Solutions for the Maximum Subsequence
Sum Problem 60
2.4.4 Logarithms in the Running Time 66
2.4.5 Limitations of Worst-Case Analysis 70
Summary 70
Exercises 71
References 76

Chapter 3 Lists, Stacks, and Queues 77


3.1 Abstract Data Types (ADTs) 77
3.2 The List ADT 78
3.2.1 Simple Array Implementation of Lists 78
3.2.2 Simple Linked Lists 79
3.3 vector and list in the STL 80
3.3.1 Iterators 82
3.3.2 Example: Using erase on a List 83
3.3.3 const_iterators 84
3.4 Implementation of vector 86
3.5 Implementation of list 91
3.6 The Stack ADT 103
3.6.1 Stack Model 103
3.6.2 Implementation of Stacks 104
3.6.3 Applications 104
3.7 The Queue ADT 112
3.7.1 Queue Model 113
3.7.2 Array Implementation of Queues 113
3.7.3 Applications of Queues 115
Summary 116
Exercises 116
Contents ix

Chapter 4 Trees 121


4.1 Preliminaries 121
4.1.1 Implementation of Trees 122
4.1.2 Tree Traversals with an Application 123
4.2 Binary Trees 126
4.2.1 Implementation 128
4.2.2 An Example: Expression Trees 128
4.3 The Search Tree ADT—Binary Search Trees 132
4.3.1 contains 134
4.3.2 findMin and findMax 135
4.3.3 insert 136
4.3.4 remove 139
4.3.5 Destructor and Copy Constructor 141
4.3.6 Average-Case Analysis 141
4.4 AVL Trees 144
4.4.1 Single Rotation 147
4.4.2 Double Rotation 149
4.5 Splay Trees 158
4.5.1 A Simple Idea (That Does Not Work) 158
4.5.2 Splaying 160
4.6 Tree Traversals (Revisited) 166
4.7 B-Trees 168
4.8 Sets and Maps in the Standard Library 173
4.8.1 Sets 173
4.8.2 Maps 174
4.8.3 Implementation of set and map 175
4.8.4 An Example That Uses Several Maps 176
Summary 181
Exercises 182
References 189

Chapter 5 Hashing 193


5.1 General Idea 193
5.2 Hash Function 194
5.3 Separate Chaining 196
5.4 Hash Tables without Linked Lists 201
5.4.1 Linear Probing 201
5.4.2 Quadratic Probing 202
5.4.3 Double Hashing 207
5.5 Rehashing 208
5.6 Hash Tables in the Standard Library 210
x Contents

5.7 Hash Tables with Worst-Case O(1) Access 212


5.7.1 Perfect Hashing 213
5.7.2 Cuckoo Hashing 215
5.7.3 Hopscotch Hashing 227
5.8 Universal Hashing 230
5.9 Extendible Hashing 233
Summary 236
Exercises 237
References 241

Chapter 6 Priority Queues (Heaps) 245


6.1 Model 245
6.2 Simple Implementations 246
6.3 Binary Heap 247
6.3.1 Structure Property 247
6.3.2 Heap-Order Property 248
6.3.3 Basic Heap Operations 249
6.3.4 Other Heap Operations 252
6.4 Applications of Priority Queues 257
6.4.1 The Selection Problem 258
6.4.2 Event Simulation 259
6.5 d-Heaps 260
6.6 Leftist Heaps 261
6.6.1 Leftist Heap Property 261
6.6.2 Leftist Heap Operations 262
6.7 Skew Heaps 269
6.8 Binomial Queues 271
6.8.1 Binomial Queue Structure 271
6.8.2 Binomial Queue Operations 271
6.8.3 Implementation of Binomial Queues 276
6.9 Priority Queues in the Standard Library 282
Summary 283
Exercises 283
References 288

Chapter 7 Sorting 291


7.1 Preliminaries 291
7.2 Insertion Sort 292
7.2.1 The Algorithm 292
7.2.2 STL Implementation of Insertion Sort 293
7.2.3 Analysis of Insertion Sort 294
7.3 A Lower Bound for Simple Sorting Algorithms 295
Contents xi

7.4 Shellsort 296


7.4.1 Worst-Case Analysis of Shellsort 297
7.5 Heapsort 300
7.5.1 Analysis of Heapsort 301
7.6 Mergesort 304
7.6.1 Analysis of Mergesort 306
7.7 Quicksort 309
7.7.1 Picking the Pivot 311
7.7.2 Partitioning Strategy 313
7.7.3 Small Arrays 315
7.7.4 Actual Quicksort Routines 315
7.7.5 Analysis of Quicksort 318
7.7.6 A Linear-Expected-Time Algorithm for Selection 321
7.8 A General Lower Bound for Sorting 323
7.8.1 Decision Trees 323
7.9 Decision-Tree Lower Bounds for Selection Problems 325
7.10 Adversary Lower Bounds 328
7.11 Linear-Time Sorts: Bucket Sort and Radix Sort 331
7.12 External Sorting 336
7.12.1 Why We Need New Algorithms 336
7.12.2 Model for External Sorting 336
7.12.3 The Simple Algorithm 337
7.12.4 Multiway Merge 338
7.12.5 Polyphase Merge 339
7.12.6 Replacement Selection 340
Summary 341
Exercises 341
References 347

Chapter 8 The Disjoint Sets Class 351


8.1 Equivalence Relations 351
8.2 The Dynamic Equivalence Problem 352
8.3 Basic Data Structure 353
8.4 Smart Union Algorithms 357
8.5 Path Compression 360
8.6 Worst Case for Union-by-Rank and Path Compression 361
8.6.1 Slowly Growing Functions 362
8.6.2 An Analysis by Recursive Decomposition 362
8.6.3 An O( M log * N ) Bound 369
8.6.4 An O( M α(M, N) ) Bound 370
8.7 An Application 372
xii Contents

Summary 374
Exercises 375
References 376

Chapter 9 Graph Algorithms 379


9.1 Definitions 379
9.1.1 Representation of Graphs 380
9.2 Topological Sort 382
9.3 Shortest-Path Algorithms 386
9.3.1 Unweighted Shortest Paths 387
9.3.2 Dijkstra’s Algorithm 391
9.3.3 Graphs with Negative Edge Costs 400
9.3.4 Acyclic Graphs 400
9.3.5 All-Pairs Shortest Path 404
9.3.6 Shortest Path Example 404
9.4 Network Flow Problems 406
9.4.1 A Simple Maximum-Flow Algorithm 408
9.5 Minimum Spanning Tree 413
9.5.1 Prim’s Algorithm 414
9.5.2 Kruskal’s Algorithm 417
9.6 Applications of Depth-First Search 419
9.6.1 Undirected Graphs 420
9.6.2 Biconnectivity 421
9.6.3 Euler Circuits 425
9.6.4 Directed Graphs 429
9.6.5 Finding Strong Components 431
9.7 Introduction to NP-Completeness 432
9.7.1 Easy vs. Hard 433
9.7.2 The Class NP 434
9.7.3 NP-Complete Problems 434
Summary 437
Exercises 437
References 445

Chapter 10 Algorithm Design Techniques 449


10.1 Greedy Algorithms 449
10.1.1 A Simple Scheduling Problem 450
10.1.2 Huffman Codes 453
10.1.3 Approximate Bin Packing 459
10.2 Divide and Conquer 467
10.2.1 Running Time of Divide-and-Conquer Algorithms 468
10.2.2 Closest-Points Problem 470
Contents xiii

10.2.3 The Selection Problem 475


10.2.4 Theoretical Improvements for Arithmetic Problems 478
10.3 Dynamic Programming 482
10.3.1 Using a Table Instead of Recursion 483
10.3.2 Ordering Matrix Multiplications 485
10.3.3 Optimal Binary Search Tree 487
10.3.4 All-Pairs Shortest Path 491
10.4 Randomized Algorithms 494
10.4.1 Random-Number Generators 495
10.4.2 Skip Lists 500
10.4.3 Primality Testing 503
10.5 Backtracking Algorithms 506
10.5.1 The Turnpike Reconstruction Problem 506
10.5.2 Games 511
Summary 518
Exercises 518
References 527

Chapter 11 Amortized Analysis 533


11.1 An Unrelated Puzzle 534
11.2 Binomial Queues 534
11.3 Skew Heaps 539
11.4 Fibonacci Heaps 541
11.4.1 Cutting Nodes in Leftist Heaps 542
11.4.2 Lazy Merging for Binomial Queues 544
11.4.3 The Fibonacci Heap Operations 548
11.4.4 Proof of the Time Bound 549
11.5 Splay Trees 551
Summary 555
Exercises 556
References 557

Chapter 12 Advanced Data Structures


and Implementation 559
12.1 Top-Down Splay Trees 559
12.2 Red-Black Trees 566
12.2.1 Bottom-Up Insertion 567
12.2.2 Top-Down Red-Black Trees 568
12.2.3 Top-Down Deletion 570
12.3 Treaps 576
xiv Contents

12.4 Suffix Arrays and Suffix Trees 579


12.4.1 Suffix Arrays 580
12.4.2 Suffix Trees 583
12.4.3 Linear-Time Construction of Suffix Arrays and Suffix Trees 586
12.5 k-d Trees 596
12.6 Pairing Heaps 602
Summary 606
Exercises 608
References 612

Appendix A Separate Compilation of


Class Templates 615
A.1 Everything in the Header 616
A.2 Explicit Instantiation 616

Index 619
P R E FAC E

Purpose/Goals
The fourth edition of Data Structures and Algorithm Analysis in C++ 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 can handle 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 centuries 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 course or a first-year
graduate course in algorithm analysis. Students should have some knowledge of inter-
mediate programming, including such topics as pointers, recursion, and object-based
programming, as well as some background in discrete math.

Approach
Although the material in this text is largely language-independent, programming requires
the use of a specific language. As the title implies, we have chosen C++ for this book.
C++ has become a leading systems programming language. In addition to fixing many
of the syntactic flaws of C, C++ provides direct constructs (the class and template) to
implement generic data structures as abstract data types.
The most difficult part of writing this book was deciding on the amount of C++ to
include. Use too many features of C++ and one gets an incomprehensible text; use too few
and you have little more than a C text that supports classes.
The approach we take is to present the material in an object-based approach. As such,
there is almost no use of inheritance in the text. We use class templates to describe generic
data structures. We generally avoid esoteric C++ features and use the vector and string
classes that are now part of the C++ standard. Previous editions have implemented class
templates by separating the class template interface from its implementation. Although
this is arguably the preferred approach, it exposes compiler problems that have made it xv
xvi Preface

difficult for readers to actually use the code. As a result, in this edition the online code
represents class templates as a single unit, with no separation of interface and implementa-
tion. Chapter 1 provides a review of the C++ features that are used throughout the text and
describes our approach to class templates. Appendix A describes how the class templates
could be rewritten to use separate compilation.
Complete versions of the data structures, in both C++ and Java, are available on
the Internet. We use similar coding conventions to make the parallels between the two
languages more evident.

Summary of the Most Significant Changes in the Fourth Edition


The fourth edition incorporates numerous bug fixes, and many parts of the book have
undergone revision to increase the clarity of presentation. In addition,

r Chapter 4 includes implementation of the AVL tree deletion algorithm—a topic often
requested by readers.
r Chapter 5 has been extensively revised and enlarged and now contains material on
two newer algorithms: cuckoo hashing and hopscotch hashing. Additionally, a new
section on universal hashing has been added. Also new is a brief discussion of the
unordered_set and unordered_map class templates introduced in C++11.
r Chapter 6 is mostly unchanged; however, the implementation of the binary heap makes
use of move operations that were introduced in C++11.
r Chapter 7 now contains material on radix sort, and a new section on lower-bound
proofs has been added. Sorting code makes use of move operations that were
introduced in C++11.
r Chapter 8 uses the new union/find analysis by Seidel and Sharir and shows the
O( M α(M, N) ) bound instead of the weaker O( M log∗ N ) bound in prior editions.
r Chapter 12 adds material on suffix trees and suffix arrays, including the linear-time
suffix array construction algorithm by Karkkainen and Sanders (with implementation).
The sections covering deterministic skip lists and AA-trees have been removed.
r Throughout the text, the code has been updated to use C++11. Notably, this means
use of the new C++11 features, including the auto keyword, the range for loop, move
construction and assignment, and uniform initialization.

Overview
Chapter 1 contains review material on discrete math and 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 5. Chapter 1 also
includes material that serves as a review of basic C++. Included is a discussion of templates
and important constructs in C++ class design.
Chapter 2 deals with algorithm analysis. This chapter explains asymptotic analysis
and its major weaknesses. Many examples are provided, including an in-depth explana-
tion 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 7, where it is performed in detail.
Preface xvii

Chapter 3 covers lists, stacks, and queues. This chapter includes a discussion of the STL
vector and list classes, including material on iterators, and it provides implementations
of a significant subset of the STL vector and list classes.
Chapter 4 covers trees, with an emphasis on search trees, including external search
trees (B-trees). The UNIX file system and expression trees are used as examples. AVL trees
and splay trees are introduced. 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. Included is a discussion of the STL set and map classes,
including a significant example that illustrates the use of three separate maps to efficiently
solve a problem.
Chapter 5 discusses hash tables, including the classic algorithms such as sepa-
rate chaining and linear and quadratic probing, as well as several newer algorithms,
namely cuckoo hashing and hopscotch hashing. Universal hashing is also discussed, and
extendible hashing is covered at the end of the chapter.
Chapter 6 is about priority queues. Binary heaps are covered, and there is additional
material on some of the theoretically interesting implementations of priority queues. The
Fibonacci heap is discussed in Chapter 11, and the pairing heap is discussed in Chapter 12.
Chapter 7 covers sorting. It is very specific with respect to coding details and analysis.
All the important general-purpose sorting algorithms are covered and compared. Four
algorithms are analyzed in detail: insertion sort, Shellsort, heapsort, and quicksort. New to
this edition is radix sort and lower bound proofs for selection-related problems. External
sorting is covered at the end of the chapter.
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 tech-
niques. 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 structures from Chapters 4 and
6 and the Fibonacci heap, introduced in this chapter, are analyzed.
Chapter 12 covers search tree algorithms, the suffix tree and array, 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 along with AVL trees (in
Chapter 4).
Chapters 1 to 9 provide enough material for most one-semester data structures courses.
If time permits, then Chapter 10 can be covered. A graduate course on algorithm analysis
could cover chapters 7 to 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
xviii Preface

is far too brief to be used in such a course. You might find it useful to use an additional
work on NP-completeness to augment this text.

Exercises
Exercises, provided at the end of each chapter, match the order in which material is pre-
sented. 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.

References
References are placed at the end of each chapter. Generally the references either are his-
torical, representing the original source of the material, or they represent extensions and
improvements to the results given in the text. Some references represent solutions to
exercises.

Supplements
The following supplements are available to all readers at http://cssupport.pearsoncmg.com/

r Source code for example programs


r Errata

In addition, the following material is available only to qualified instructors at Pearson


Instructor Resource Center (www.pearsonhighered.com/irc). Visit the IRC or contact your
Pearson Education sales representative for access.

r Solutions to selected exercises


r Figures from the book
r Errata

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.
As usual, the writing process was made easier by the professionals at Pearson. I’d like
to thank my editor, Tracy Johnson, and production editor, Marilyn Lloyd. My wonderful
wife Jill deserves extra special thanks for everything she does.
Finally, I’d like to thank the numerous readers who have sent e-mail messages and
pointed out errors or inconsistencies in earlier versions. My website www.cis.fiu.edu/~weiss
will also contain updated source code (in C++ and Java), an errata list, and a link to submit
bug reports.
M.A.W.
Miami, Florida
C H A P T E R 1

Programming: A General
Overview

In this chapter, we discuss the aims and goals of this text and briefly review programming
concepts and discrete mathematics. We will . . .

r See that how a program performs for reasonably large input is just as important as its
performance on moderate amounts of input.
r Summarize the basic mathematical background needed for the rest of the book.
r Briefly review recursion.
r Summarize some important features of C++ that are used throughout the text.

1.1 What’s This Book About?


Suppose you have a group of N numbers and would like to determine the kth 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 bubble sort, 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 new
element arrives, it is ignored if it is smaller than the kth element in the array. Otherwise, it
is placed in its correct spot in the array, bumping one element out of the array. When the
algorithm ends, the element in the kth position is returned as the answer.
Both algorithms are simple to code, and you are encouraged to do so. The natural ques-
tions, then, are: Which algorithm is better? And, more important, Is either algorithm good
enough? A simulation using a random file of 30 million elements and k = 15,000,000
will show that neither algorithm finishes in a reasonable amount of time; each requires
several days of computer processing to terminate (albeit eventually with a correct answer).
An alternative method, discussed in Chapter 7, gives a solution in about a second. Thus,
although our proposed algorithms work, they cannot be considered good algorithms, 1
2 Chapter 1 Programming: A General Overview

1 2 3 4

1 t h i s
2 w a t s
3 o a h g
4 f g d t

Figure 1.1 Sample word puzzle

because they are entirely impractical for input sizes that a third algorithm can handle in a
reasonable amount of time.
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 the puzzle.
These words may be horizontal, vertical, or diagonal in any direction. As an example, the
puzzle shown in Figure 1.1 contains the words this, two, fat, 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 straightforward algorithms that solve the problem. For each
word in the word list, we check each ordered triple (row, column, orientation) for the pres-
ence 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 might not be acceptable.
However, it is possible, even with a large word list, to solve the problem very quickly.
An important concept is that, in many problems, writing a working program is not
good enough. If the program is to be run on 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.

1.2 Mathematics Review


This section lists some of the basic formulas you need to memorize, or be able to derive,
and reviews basic proof techniques.
1.2 Mathematics Review 3

1.2.1 Exponents
XA XB = XA+B
XA
= XA−B
XB
(XA )B = XAB
XN + XN = 2XN = X2N
2N + 2N = 2N+1

1.2.2 Logarithms
In computer science, all logarithms are to the base 2 unless specified otherwise.
Definition 1.1
XA = B if and only if logX B = A
Several convenient equalities follow from this definition.
Theorem 1.1

logC B
logA B = ; A, B, C > 0, A = 1
logC A

Proof
Let X = logC B, Y = logC A, and Z = logA B. Then, by the definition of loga-
rithms, CX = B, CY = A, and AZ = B. Combining these three equalities yields
B = CX = (CY )Z . Therefore, X = YZ, which implies Z = X/Y, proving the theorem.
Theorem 1.2

log AB = log A + log B; A, B > 0

Proof
Let X = log A, Y = log B, and Z = log AB. Then, assuming the default base of 2,
2X = A, 2Y = B, and 2Z = AB. Combining the last three equalities yields
2X 2Y = AB = 2Z . Therefore, X + Y = Z, which proves the theorem.
Some other useful formulas, which can all be derived in a similar manner, follow.

log A/B = log A − log B

log(AB ) = B log A

log X < X for all X > 0

log 1 = 0, log 2 = 1, log 1,024 = 10, log 1,048,576 = 20


4 Chapter 1 Programming: A General Overview

1.2.3 Series
The easiest formulas to remember are

N
2i = 2N+1 − 1
i=0

and the companion,



N
AN+1 − 1
Ai =
A−1
i=0

In the latter formula, if 0 < A < 1, then



N
1
Ai ≤
1−A
i=0

and as N tends to ∞, the sum approaches 1/(1 − A). These are the “geometric series”
formulas. 
We can derive the last formula for ∞i=0 A (0 < A < 1) in the following manner. Let
i

S be the sum. Then


S = 1 + A + A2 + A3 + A4 + A5 + · · ·
Then
AS = A + A2 + A3 + A4 + A5 + · · ·
If we subtract these two equations (which is permissible only for a convergent series),
virtually all the terms on the right side cancel, leaving
S − AS = 1
which implies that
1
S=
1−A

We can use this same technique to compute ∞ i
i=1 i/2 , a sum that occurs frequently.
We write
1 2 3 4 5
S = + 2 + 3 + 4 + 5 + ···
2 2 2 2 2
and multiply by 2, obtaining
2 3 4 5 6
2S = 1 + + + 3 + 4 + 5 + ···
2 22 2 2 2
Subtracting these two equations yields
1 1 1 1 1
S=1+ + + 3 + 4 + 5 + ···
2 22 2 2 2
Thus, S = 2.
1.2 Mathematics Review 5

Another type of common series in analysis is the arithmetic series. Any such series can
be evaluated from the basic formula:


N
N(N + 1) N2
i= ≈
2 2
i=1

For instance, to find the sum 2 + 5 + 8 + · · · + (3k − 1), rewrite it as 3(1 + 2 + 3 +


· · · + k) − (1 + 1 + 1 + · · · + 1), which is clearly 3k(k + 1)/2 − k. Another way to remember
this is to add the first and last terms (total 3k + 1), the second and next-to-last terms (total
3k + 1), and so on. Since there are k/2 of these pairs, the total sum is k(3k + 1)/2, which
is the same answer as before.
The next two formulas pop up now and then but are fairly uncommon.


N
N(N + 1)(2N + 1) N3
i2 = ≈
6 3
i=1

N
Nk+1
ik ≈ k = −1
|k + 1|
i=1

When k = −1, the latter formula is not valid. We then need the following formula,
which is used far more in computer science than in other mathematical disciplines. The
numbers HN are known as the harmonic numbers, and the sum is known as a harmonic
sum. The error in the following approximation tends to γ ≈ 0.57721566, which is known
as Euler’s constant.


N
1
HN = ≈ loge N
i
i=1

These two formulas are just general algebraic manipulations:


N
f(N) = Nf(N)
i=1

N 
N 0 −1
n
f(i) = f(i) − f(i)
i=n0 i=1 i=1

1.2.4 Modular Arithmetic


We say that A is congruent to B modulo N, written A ≡ B (mod N), if N divides
A − B. Intuitively, this means that the remainder is the same when either A or B is
divided by N. Thus, 81 ≡ 61 ≡ 1 (mod 10). As with equality, if A ≡ B (mod N), then
A + C ≡ B + C (mod N) and AD ≡ BD (mod N).
6 Chapter 1 Programming: A General Overview

Often, N is a prime number. In that case, there are three important theorems:

First, if N is prime, then ab ≡ 0 (mod N) is true if and only if a ≡ 0 (mod N)


or b ≡ 0 (mod N). In other words, if a prime number N divides a product of two
numbers, it divides at least one of the two numbers.
Second, if N is prime, then the equation ax ≡ 1 (mod N) has a unique solution
(mod N) for all 0 < a < N. This solution, 0 < x < N, is the multiplicative inverse.
Third, if N is prime, then the equation x2 ≡ a (mod N) has either two solutions
(mod N) for all 0 < a < N, or it has no solutions.

There are many theorems that apply to modular arithmetic, and some of them require
extraordinary proofs in number theory. We will use modular arithmetic sparingly, and the
preceding theorems will suffice.

1.2.5 The P Word


The two most common ways of proving statements in data-structure analysis are proof
by induction and proof by contradiction (and occasionally proof by intimidation, used
by professors only). The best way of proving that a theorem is false is by exhibiting a
counterexample.

Proof by Induction
A proof by induction has two standard parts. The first step is proving a base case, that is,
establishing that a theorem is true for some small (usually degenerate) value(s); this step is
almost always trivial. Next, an inductive hypothesis is assumed. Generally this means that
the theorem is assumed to be true for all cases up to some limit k. Using this assumption,
the theorem is then shown to be true for the next value, which is typically k + 1. This
proves the theorem (as long as k is finite).
As an example, we prove that the Fibonacci numbers, F0 = 1, F1 = 1, F2 = 2, F3 = 3,
F4 = 5, . . . , Fi = Fi−1 + Fi−2 , satisfy Fi < (5/3)i , for i ≥ 1. (Some definitions have F0 = 0,
which shifts the series.) To do this, we first verify that the theorem is true for the trivial
cases. It is easy to verify that F1 = 1 < 5/3 and F2 = 2 < 25/9; this proves the basis.
We assume that the theorem is true for i = 1, 2, . . . , k; this is the inductive hypothesis. To
prove the theorem, we need to show that Fk+1 < (5/3)k+1 . We have

Fk+1 = Fk + Fk−1

by the definition, and we can use the inductive hypothesis on the right-hand side,
obtaining

Fk+1 < (5/3)k + (5/3)k−1


< (3/5)(5/3)k+1 + (3/5)2 (5/3)k+1
< (3/5)(5/3)k+1 + (9/25)(5/3)k+1
which simplifies to
Another Random Document on
Scribd Without Any Related Topics
neighbours, for implements and objects of adornment, and the
commerce of an age when fleets traverse the seas, and eventually
ships course through the air, uniting the peoples of all parts of the
world into one great commercial community! We cannot undertake
to delineate all aspects of this development, for the latter includes
the entire history of mankind. Our concern is merely to indicate the
outstanding psychological factors fundamental to the progression of
the later from that which was original, of the more perfect from the
primitive, partly under the pressure of external conditions of life and
partly as a result of man's own creative power.

CHAPTER I

PRIMITIVE MAN

1. THE DISCOVERY OF PRIMITIVE MAN.

Who is the primitive man? Where is he to be found? What are his


characteristics? These are the important questions which here at
once confront us. But they are questions to which, strangely enough,
the answer has, up to very recent times, been sought, not in the
facts of experience, history, or ethnology, but purely by the path of
speculation. At the outset the search was not, for the most part,
based on investigations of primitive culture itself, but took as its
starting-point contemporary culture and present-day man. It was
primarily by means of an abstract opposition of culture to nature
that philosophy, and even anthropology, constructed natural man.
The endeavour was not to find or to observe, but to invent him. It
was simply by antithesis to cultural man that the image of natural
man took shape; the latter is one who lacks all the attainments of
culture. This is the negative criterion by means of which the
philosophy of the Enlightenment, with its conceited estimate of
cultural achievements, formed its idea of primitive man. Primitive
man is the savage; the savage, however, is essentially an animal
equipped with a few human qualities, with language and a fragment
of reason just sufficient to enable him to advance beyond his
deplorable condition. Man in his natural state, says Thomas Hobbes,
is toward man as a wolf. He lives with his fellow-beings as an animal
among animals, in a struggle for survival. It is the contrast of wild
nature with peaceful culture, of ordered State with unorganized herd
or horde, that underlies this conception.
But this antithesis between the concepts of culture and of nature, as
objectively considered, is not the only factor here operative; even
more influential is the contrast between the subjective moods
aroused by the actual world and by the realm disclosed by
imagination or reason. Hence it is that the repelling picture of
primitive man is modified as soon as the mood changes. To an age
that is satiated with culture and feels the traditional forms of life to
be a burdensome constraint, the state of nature becomes an ideal
once realized in a bygone world. In contrast to the wild creature of
Thomas Hobbes and his contemporaries, we have the natural man of
Jean Jacques Rousseau. The state of nature is a state of peace,
where men, united in love, lead a life that is unfettered and free
from want.
Alongside of these constructions of the character of natural man,
however, there early appeared a different method of investigation,
whose aim it was to adhere more closely to empirical facts. Why
should we not regard those of our human institutions which still
appear to be a direct result of natural conditions as having existed in
the earliest period of our race? Marriage and the family, for example,
are among such permanent cultural institutions, the one as the
natural union of the sexes, the other as its necessary result. If
marriage and family existed from the beginning, then all culture has
grown out of the extension of these primitive associations. The
family first developed into the patriarchal joint family; from this the
village community arose, and then, through the union of several
village communities, the State. The theory of a natural development
of society from the family was first elaborated by Aristotle, but it
goes back in its fundamental idea to legend and myth. Peoples
frequently trace their origin to an original pair of ancestors. From a
single marriage union is derived the single tribe, and then, through a
further extension of this idea, the whole of mankind. The legend of
an original ancestral pair, however, is not to be found beyond the
limits of the monogamous family. Thus, it is apparently a projection
of monogamous marriage into the past, into the beginnings of a
race, a tribe, or of mankind. Wherever, therefore, monogamous
marriage is not firmly established, legend accounts for the origin of
men and peoples in various other ways. It thinks of them as coming
forth from stones, from the earth, or from caverns; it regards
animals as their ancestors, etc. Even the Greek legend of Deukalion
and Pyrrha contains a survival of such an earlier view, combined
with the legend of an original ancestral pair. Deukalion and Pyrrha
throw stones behind them, from which there springs a new race of
men.
The thought of an original family, thus, represents simply a
projection of the present-day family into an inaccessible past.
Clearly, therefore, it is to be regarded as only an hypothesis or,
rather, a fiction. Without the support which it received from the
Biblical legend, it could scarcely have maintained itself almost down
to the present, as it did in the patriarchal theory of the original state
of man to which it gave rise. The Aristotelian theory of the gradual
origin of more comprehensive organizations, terminating in the
State, is no less a fiction; the social communities existing side by
side in the period of Greece were arbitrarily represented as having
emerged successively in the course of history. Quite naturally,
therefore, this philosophical hypothesis, in common with the
corresponding legend of the original family, presupposes primitive
man to have possessed the same characteristics as the man of to-
day. Thus, it gives no answer at all to the question concerning the
nature of this primitive man.
When, therefore, modern anthropology made the first attempt to
answer this question on the basis of empirical facts, it was but
natural to assume that the characteristics of original man were not
to be learned from a study of existing peoples, nor, indeed, from
history, but that the data for the solution of the problem were of a
prehistoric nature, to be found particularly in those human remains
and those products of man's activity that have been preserved in the
strata of the earth's crust. What we no longer find on the earth, so it
was held, we must seek under the earth. And thus, about six
decades ago, prehistoric anthropology began to gather material, and
this has gradually grown to a considerable bulk. Upon the
completion of this task, however, it appeared, as might, of course,
have been expected, that psychology could gain but little in this way.
The only source from which it might derive information lay in the
exhumed objects of art. Then, however, the very disappointing
discovery was made that, as regards implements of stone, drawings
on the walls of caves which he inhabited, and pictures cut into horn
or bone, the artistic achievements of the man of diluvial times did
not differ essentially from those of the present-day savage. In so far
as physical characteristics are concerned, however, the discovered
remains of bones seemed to point to certain differences. While these
differences, of course, were incapable of establishing any direct
psychological conclusions, the fact that the measurements of the
skeletal parts more closely resembled those of animals, and, in
particular, that the measurements of the interior of the skull were
smaller than those of the savages of our own time, offered indirect
evidence of a lower development. Because of the close relation of
cranial capacity to size of brain, moreover, a lower degree of
intelligence was also indicated. Nevertheless, the remains that have
been brought to light have not as yet led to any indubitable
conclusions. There have been fairly numerous discoveries pointing to
races that resemble the lower tribes among contemporary peoples,
and but a few cases in which uncertainty is possible, and concerning
which, therefore, there exists a conflict of opinions. A typical
instance is the history of one of the first discoveries made in Europe
of the remains of a prehistoric man. It was in 1856, in German
territory, that there was discovered, in a grotto or cave in the
Neander valley, near Duesseldorf, a very remarkable skull, though
only, of course, the bones of the cranium and not the facial bones.
All were at once agreed that these were the remains of a very
primitive man. This was indicated particularly by characteristics
which are still to be found, though scarcely in so pronounced a form,
among certain lower races of men. Of special significance were the
strongly developed, prominent bone-elevations above the eye-
sockets. Some of the investigators believed that the long-sought
'homo primigenius' had perhaps at last been discovered. It was
generally agreed that the form of the skull resembled most closely
that of the modern Australian. In more recent years, however,
anthropologists have developed somewhat more exact methods of
measurement and of the reconstruction of a skeleton from parts only
incompletely given. When Hermann Klaatsch, equipped with this
knowledge, carried out such a reconstruction of the Neanderthal
skull, he came upon the surprising fact that its capacity was
somewhat greater than that of the present-day Australian. Little as
this tells us concerning the actual intelligence of these primitive
men, it nevertheless clearly indicates how uncertain the conclusions
of prehistoric anthropology still are. A number of other recent
discoveries in Germany, France, and elsewhere, have proved that
several prehistoric races of men once lived in Europe. Some of these,
no doubt, date back far beyond the last glacial period, and perhaps
even beyond the period preceding this, for we now know that
several glacial periods here succeeded one another. Nevertheless, no
important divergencies from still existent races of men have been
found. This, of course, does not imply that no differences exist; it
means merely that none has as yet been positively detected, and
that therefore the anatomy of prehistoric man can give us no
information concerning the psychological aspect of the question
regarding the nature of primitive man.
Considerably more light is thrown on this question when we examine
the products of human activity, such as implements, weapons, and
works of art. Traces of man, in the form of objects hammered out of
flint and shaped into clubs, chisels, knives, and daggers, capable of
serving as implements of daily use no less than as weapons, are to
be found as far back as the first diluvian epoch, and, in their crudest
forms, perhaps even as early as the tertiary period. The more
polished objects of similar form belong to a later age. Still more
remarkable are the works of art—in particular, the cave pictures of
prehistoric animals, such as the cave bear and the mammoth.
Nevertheless, none of these achievements is of such a nature as to
afford positive evidence of a culture essentially different from, or
lower than, that of the primitive man of to-day. Two outstanding
facts, especially, make a comparison difficult. On the one hand,
wood plays an important rôle in the life of modern primitive man,
being used for the construction of tools, weapons, and, in part, also
of baskets and vessels. But the utensils of wood that may have
existed in prehistoric times could not have withstood the destructive
forces of decomposition and decay. All such utensils, therefore, that
prehistoric man may have possessed have been lost. Thus, for
example, it will be difficult ever to ascertain whether or not he was
familiar with the bow and arrow, since the arrow, as well as the bow,
was originally made of wood. Secondly, there is at the present time
no primitive tribe, however much shut off from its more remote
environment, into which barter, which is nowhere entirely absent,
may not introduce some objects representing a higher form of
civilization, particularly metals and metal implements. If, however,
we bear in mind that, in the one case, products have suffered
destruction and that, in the other, articles have been introduced from
without, the impression made by prehistoric utensils and products of
art—aside from certain doubtful remains dating back beyond the
diluvial epoch—is not essentially different from that made by the
analogous products of the Negritos of the Philippines or the inland
tribes of Ceylon. Though the material of which the implements are
constructed differs, the knives, hammers, and axes in both instances
possess the usual form. Thus, the wooden knife which the Veddah of
Ceylon still carves out of bamboo is formed precisely like some of
the stone knives of the diluvial period. We find a similar
correspondence when we examine the traces of dwellings and
decorations that have been preserved, as well as certain remains
that throw light upon customs. The oldest prehistoric people of
Europe dwelt in caves, just as the primitive man of the tropics does
to-day in the rainy season. In a rock cavern near Le Moustier, in
France, there was discovered a skeleton whose crouching position
points to a mode of burial still prevalent among primitive peoples,
and one which is doubtless always a fairly positive indication of a
belief in demons such as arises in connection with the impression
made by death. The dead person is bound in the position that will
best prevent his return. Thus, all these prehistoric remains suggest a
culture similar to that of primitive tribes of to-day. But, just because
they reveal conditions not essentially different from those of the
present, these remains make another important contribution to our
knowledge of primitive man. They indicate the great stability of
primitive culture in general, and render it probable that, unless there
are special conditions making for change, such as migrations and
racial fusions, the stability increases in proportion to the antiquity.
Though this may at first glance seem surprising, it becomes
intelligible when we consider that isolation from his surroundings is
an important characteristic of primitive man. Having very little
contact with other peoples, he is in no wise impelled to change the
modes of action to which his environment has led him from
immemorial times.
Thus, the correspondence of the prehistoric with that which is to-day
primitive indicates a high degree of permanence on the part of
primitive culture. But, even apart from this consideration, it is
apparent that we must really seek primitive man in the inhabited
world of the present, since it is here alone that we can gain a
relatively accurate knowledge of his characteristics. Our information
concerning primitive man, therefore, must be derived from
ethnology. We must not seek him under the earth, but on the earth.
Just where, however, is he to be found? For decades the natives of
Australia were believed to represent a perfect example of primitive
culture. And, as a matter of fact, their material culture and some of
their mythological ideas still seem to be of a very primitive character.
Because of the conjecture that it was here dealing with a relatively
primitive type of man, modern anthropology has for two decades
applied itself with great partiality to the study of Australian tribes.
English and German investigators have given us many works, some
of them excellent, treating of the continent of Australia, which
appears almost as unique with respect to its population as in its flora
and its fauna. From these investigations, however, which are
reported particularly in the volume by Howitt published in 1900, in
the works of Spencer and Gillen, and, finally, in those of Strehlow, a
German missionary, it is apparent that the Australian culture is
anything but primitive: it represents, rather, a stage of development
already somewhat advanced. In certain respects, indeed, it may
contain very primitive elements, such as are not to be found even
among tribes that are, on the whole, on a lower level. Australian
culture, however, possesses an enormously complex social
organization, and this places it above that which may be called
primitive. In its present form, it presupposes a development of
probably thousands of years. Assuredly, therefore, the Australian
should not be included in a chapter on primitive man. He will rather
claim our attention in the next chapter, as a well-defined type of the
totemic age. Indeed, he is beginning, in part, to lose even the
characteristics of this age, mainly, no doubt as a result of racial
fusion, whose influence is here also in evidence.
Although the races of Australia are unquestionably not primitive, as
was formerly believed and is still held in certain quarters, there are
other parts of the earth which, in all probability, really harbour men
who are primitive in that relative sense of the term which alone, of
course, we are justified in using. If one were to connect the
discovery of this primitive man with any single name, the honour
would belong to a German traveller and investigator, George
Schweinfurth. He was the first to discover a really primitive tribe—
that is, one which remained practically untouched by external
cultural influences. When Schweinfurth, sailing up the Upper Nile in
1870, listened to the narratives of the Nubian sailors in charge of his
boat, he repeatedly heard accounts of a nation of dwarfs, of people
two feet tall (so the exaggerated reports went), living in the
impenetrable forests beyond the great lakes which constitute the
source of the Nile. Schweinfurth was at once reminded of the old
legends regarding pygmies. Such legends are mentioned even by
Homer and are introduced also into the writings of Herodotus and of
Aristotle. Aristotle, indeed, expressly says that these dwarf peoples
of Central Africa exist in reality, and not merely in tales. When
Schweinfurth arrived in the country of the Monbuttus, he was
actually fortunate enough to gain sight of these pygmies. It is true,
they did not exactly correspond to the fantastic descriptions of the
sailors—descriptions such as are current here and there even to-day.
The sailors represented the pygmies as having long beards, reaching
to the earth, and gigantic heads; in short, they imputed to them the
characteristics of the dwarf gnome, who appears also in German
folk-lore. In reality, it was found that the pygmies are, indeed, small
—far below the average normal size of man—but that they are of
excellent proportions, have small heads, and almost beardless faces.
Subsequent to Schweinfurth's discovery, similar tribes were found in
various parts of the earth. Emin Pasha, together with his companion
Stuhlmann, had the good fortune to be able to observe the pygmies
of the Congo more closely even than had been possible for
Schweinfurth. In the Negritos of the Philippines a similar dwarf
people was discovered. They also are of small stature, and,
according to their own belief and that of the neighbouring Malays,
are the original inhabitants of their forests. Besides these, there are
the inland tribes of the Malay Peninsula, the Semangs and Senoi,
and, finally, the Veddahs of Ceylon, studied particularly by the
cousins Paul and Fritz Sarasin. All of the peoples just mentioned live
in forests and have probably been isolated from civilization for
thousands of years. The Bushmen of South Africa, of whom we have
long known, also belong to this group, although they have not to the
same extent been free from the influence of surrounding peoples. In
all these cases we have to do with tribes which at one time probably
occupied wider territories, but which have now been crowded back
into the forest or wilderness. In addition to these tribes,
furthermore, there are remnants of peoples in Hindustan, in Celebes,
Sumatra, the Sunda Islands, etc. Concerning these, however, we as
yet have little knowledge. In some respects, doubtless, the
inhabitants of the Andaman Islands should also be here included,
although they cannot, on the whole, be regarded as primitive in the
strict sense of the word. This is precluded by their external culture,
and especially by their legends, the latter of which point to the
influence of Asiatic culture.
Observations of these relatively most primitive tribes—and this is
especially worth noting—-show them to be remarkably similar. If we
read a description of the characteristics, habits, and customs of the
Negritos of the Philippines and then pass on to the Malaccans, to the
Semangs and Senoi, or, further, to the Veddahs of Ceylon, we
constantly meet with almost the same phenomena, there being but
slight differences depending on the specific character of the natural
environment. We are thus in possession of data that are now
observable. The statements and conclusions which these enable us
to make are more than mere speculations with regard to the past;
and they are more than inferences drawn from the silent fragments
of the bones and from a few of the art products of primitive man.
According as the phenomena are simpler in character and require
fewer antecedent conditions for their explanation, may we be
confident that we are really dealing with primitive conditions. This in
itself implies that the criteria of primitive culture are essentially
psychological in nature, and that racial characteristics and original
tribal relationships are probably negligible so far as this question is
concerned. A culture would be absolutely primitive if no antecedent
mental development whatsoever could be presupposed. Such an
absolute concept can never be realized in experience, here any more
than elsewhere. We shall, therefore, call that man primitive in the
relative sense of the term—our only remaining alternative—whose
culture approximates most nearly to the lowest mental achievements
conceivable within the limits of universal human characteristics. The
most convenient measure of these achievements, and the one lying
nearest at hand, is that afforded by external culture, as expressed in
dress, habitation, and food, in self-made implements, weapons, and
other productions serving to satisfy the most urgent needs of life.

2. THE CULTURE OF PRIMITIVE MAN IN ITS EXTERNAL


EXPRESSIONS.

Following the above-mentioned criteria as to what may be regarded


as primitive, the question concerning the external culture of primitive
man may, in general, be briefly answered. Of dress there are only
meagre beginnings: about the loins a cord of bast, to which twigs of
trees are attached to cover the genitals—that is generally all, unless,
through secret barter with neighbouring peoples, cotton goods,
leather, and the like, have been imported. As regards personal
decoration, conditions are much the same. On the next stage of
development, the totemic, there is, as we shall later see, a desire for
lavish decoration, especially as regards the adornment of the body
by painting and tatooing. Little of this, however, is to be found
among primitive tribes, and that which exists has probably been
introduced from without. Some examples of such decoration are the
scanty tatooing in single lines, the painting of the face with several
red and white dots, and the wooden plug bored through the bridge
of the nose. The Negritos of the Philippines bore holes through their
lips for the insertion of a row of blades of grass. Other decorations
found are necklaces and bracelets, fillets, combs, hair ornaments
made of twigs and flowers, and the like.
What is true of his dress holds also of the dwelling of primitive man.
Everything indicates that the first permanent dwelling was the cave.
Natural caves in the hillsides, or, less frequently, artificially
constructed hollows in the sand, are the places of refuge that
primitive man seeks when the rainy season of the tropics drives him
to shelter. During the dry season, no shelter at all is necessary; he
makes his bed under a tree, or climbs the tree to gain protection
from wild animals. Only in the open country, under the compulsion
of wind and rain, does he construct a wind-break of branches and
leaves after the pattern supplied by nature in the leafy shelter of the
forest. When the supports of this screen are inclined toward one
another and set up in a circle, the result is the original hut.
Closely connected with the real dwelling of primitive man, the cave,
are two further phenomena that date back to earliest culture. As his
constant companion, primitive man has a single animal, the dog,
doubtless the earliest of domestic animals. Of all domestic animals
this is the one that has remained most faithful to man down to the
present time. The inhabitant of the modern city still keeps a dog if
he owns any domestic animal at all, and as early as primitive times
the dog was man's faithful companion. The origin of this first
domestic animal remains obscure. The popular notion would seem to
be that man felt the need of such a companion, and therefore
domesticated the dog. But if one calls to mind the dogs that run wild
in the streets of Constantinople, or the dog's nearest relative, the
wolf, one can scarcely believe that men ever had a strong desire to
make friends of these animals. According to another widely current
view, it was man's need of the dog as a helper in the chase that led
to its domestication. But this also is one of those rationalistic
hypotheses based on the presupposition that man always acts in
accordance with a preconceived plan, and thus knew in advance that
the dog would prove a superior domestic animal, and one especially
adapted to assist in the chase. Since the dog possessed these
characteristics only after its domestication, they could not have been
known until this had occurred, and the hypothesis is clearly
untenable. How, then, did the dog and man come together in the
earliest beginnings of society? The answer to this question, I believe,
is to be found in the cave, the original place of shelter from rain and
storm. Not only was the cave a refuge for man, but it was equally so
for animals, and especially for the dog. Thus it brought its dwellers
into companionship. Furthermore, the kindling of the fire, once man
had learned the art, may have attracted the animal to its warmth.
After the dog had thus become the companion of man, it
accompanied him in his activities, including that of the chase. Here,
of course, the nature of the carnivorous animal asserted itself; as
man hunted, so also did the animal. The dog's training, therefore,
did not at all consist in being taught to chase the game. It did this of
itself, as may be observed in the case of dogs that are not
specifically hunting dogs. The training consisted rather in breaking
the dog of the habit of devouring the captured game. This was
accomplished only through a consciously directed effort on the part
of man, an effort to which he was driven by his own needs. Thus, it
is the cave that accounts for the origin of the first domestic animal,
and also, probably, for the first attempt at training an animal. But
there is still another gain for the beginnings of culture that may
probably be attributed to the cave in its capacity of a permanent
habitation. Among primitive peoples, some of whom are already
advanced beyond the level here in question, it is especially in caves
that artistic productions may be found. These consist of crude
drawings of animals and, less frequently, of men. Among the
Bushmen, such cave pictures are frequently preserved from
destruction for a considerable period of time. Natural man, roaming
at will through the forests, has neither time nor opportunity to
exercise his imagination except upon relatively small objects or upon
the adornment of his own body. But the semi-darkness of the cave
tends, as do few other places, to stimulate the reproductive
imagination. Undisturbed by external influences, and with
brightnesses and colours enhanced by the darkness, the memory
images of things seen in the open, particularly those of the animals
of the primeval forest, rise to consciousness and impel the lonely
and unoccupied inhabitant to project them upon the wall. Such
activity is favoured by the fact, verifiable by personal introspection,
that memory images are much more vivid in darkness and semi-
darkness than in the light of day. Thus, it was in the cave, the first
dwelling-place of man, that the transition was made, perhaps for the
first time, from the beginnings of a graphic art, serving the purposes
of adornment or magic, to an art unfettered except by memory. It
was an art of memory in a twofold sense: it patterned its objects
after the memory of things actually observed, and it sought to
preserve to memory that which it created.
From the consideration of dress and habitation we turn to that of
food. Primitive man was not bound to fixed hours for his meals.
Among civilized peoples, so close a connection has grown up
between meals and definite hours of the day that the German word
for meal, Mahlzeit, reminds us of this regularity by twice repeating
the word for time—-for Mahl also means time. Primitive man knew
nothing of the sort. If he found food and was hungry, he ate; if he
found none, he went hungry. Sometimes, moreover, in order to
provide for the future, he gorged to such an extent as to injure his
health. As concerns the food itself, there is an old theory which has
led to misconceptions concerning primitive man. He was a hunter,
we are told; the chase supplied him with food; only incidentally and
occasionally did he enjoy parts of plants or fruits that he had
gathered or accidentally discovered. It is scarcely correct, however,
to assume that systematic hunting was practised by primitive man.
Doubtless he did engage in this occupation. Yet this furnished him
with only an incidental part of his food supply—apart with which,
living as he did from hand to mouth, he satisfied only his momentary
needs. It was with plant food, if at all, that he made provision for
the future. Here may be found also the first traces of a division of
labour: woman gathered the plant food—roots, bulbs, and berries—
while man occasionally found it necessary to hunt. Plant food being
capable of longer preservation, it was woman who first learned to
economize and to make provision for the future. In part, indeed, the
influence of these cultural beginnings persists even to-day. Moreover,
just as mixed food, part plant and part animal, is by far the most
common to-day, so also was it the original diet of man. The
proportion, however, varied more than in later times, according as
the external conditions of life were propitious or otherwise. Of this
the Bushmen afford a striking illustration. Fifty years ago they were
still by preference huntsmen. Armed with their bows, they dared to
hunt the elephant and the giraffe. But after the surrounding peoples
of South Africa—the Hottentots, Betschuans, and Herero—came into
the possession of firearms, which the Bushman scornfully rejects,
the game was, in part, exterminated, and to-day the Bushmen,
crowded back into rocky wastes, derive but a small part of their
living from the chase. They gather bulbs, roots, and other parts of
plants, such as can be rendered edible by boiling or roasting. Their
animal food, moreover, is no longer wild game, but consists, for the
most part, of small animals found while gathering the plant food—
frogs, lizards, worms, and even insects. Hunting, therefore, was
never more than one of the customary means of providing food; and
primitive man, especially, was a gatherer rather than a hunter. The
word 'gatherer' implies also that he took from nature only what it
directly offered, and that he was familiar neither with agriculture nor
with the raising of animals. In procuring his food, moreover, he was
aided by a knowledge, often surprising, of the properties of the
objects gathered. This knowledge, probably gained as a result of
many disastrous experiences in his search for food, enabled primitive
man to utilize even such roots and fruits as are not wholesome in
their raw state, either because they are not edible until prepared by
means of fire, or because they are poisonous. Primitive man learned
to overcome the injurious effects of many of these plants. By
reducing them to small pieces, washing them in a solution of lye,
and heating them, he converted them into palatable food. The bulbs
and roots were secured from beneath the surface of the ground by
means of the most primitive of all agricultural implements and the
progenitor of all succeeding ones, the digging-stick. This is a wooden
stick, with a pointed end that has been hardened by fire.
Connected with the removal of poison, by means of water and fire,
from parts of plants that are otherwise edible, is still another
primitive discovery—the utilization of the poisons themselves. Only
when the arrow is smeared with plant poisons does the bow become
a real weapon. In itself the arrow wound is not sufficient to kill
either game or enemy; the arrow must be poisoned if the wound is
to cause death or even temporary disability. The Veddahs and the
inland tribes of Malacca therefore use the juice of the upas-tree
mixed with that of strychnos-trees. The best known of these arrow
poisons, curare, used in South America and especially in Guiana, is
likewise prepared from the juice of strychnos-trees.
This brings us to the weapons of primitive man. In this connection it
is highly important to note that all of the primitive peoples
mentioned above are familiar with the use of bow and arrow, but we
must also bear in mind that this is practically their only weapon.
Contrary to what archæological excavations would suggest
concerning the earliest age of peoples, primitive culture, in respect
to implements and weapons, depended only to a small extent upon
the working of stone. We might better speak of this period as an age
of wood. Wood is not only decidedly easier to manipulate than
stone, but it is always more easily obtainable in shapes suitable for
constructive purposes. Possibly even the arrow-head was originally
always made of wood, as it sometimes is even to-day. Only in later
times was the wood replaced by a sharpened stone or by iron
acquired through barter.
It is not difficult to see how wood, in the forms which it possesses
by nature, came to be fashioned into clubs, axes, and digging-sticks,
and how bones, horns, shells, and the like were converted into tools
and objects of adornment. But how did primitive man acquire bow
and arrow? The general belief seems to be that this weapon was
invented by some resourceful mind of an early age. But an inventor,
in the proper sense of the word, must know in advance what he
wishes to invent. The man, therefore, who constructed the bow and
arrow for the first time must already have had some previous idea of
it. To effect a combination of existing implements, or to improve
them in useful ways, is a comparatively easy matter. But no one can
manufacture implements if he possesses nothing over and above
material that is in itself somehow suitable for the purpose. The most
primitive implements, therefore, such as the digging-stick, the club,
and the hammer, are all products of nature, at most changed slightly
by man as their use requires. But this is obviously not true of bow
and arrow. We may, perhaps, find a suggestion for the solution of
our problem in a hunting weapon which, though belonging, of
course, to the later totemic culture, is in principle simpler than the
bow and arrow—the boomerang of the Australians. The word is
probably familiar to all, but the nature of the weapon is not so well
known, especially its peculiarly characteristic form by virtue of which,
if it fails to strike its object, it flies back to the one who hurled it.
The boomerang, which possesses this useful characteristic, is, in the
first place, a bent wooden missile, pointed at both ends. That this
curved form has a greater range and strikes truer to aim than a
straight spear, the Australian, of course, first learned from
experience. The boomerang, however, will not return if it is very
symmetrically constructed; on the contrary, it then falls to the
ground, where it remains. Now it appears that the two halves of this
missile are asymmetrical. One of the halves is twisted spirally, so
that the weapon, if thrown forward obliquely, will, in accordance
with the laws of ballistics, describe a curve that returns upon itself.
This asymmetry, likewise, was discovered accidentally. In this case,
the discovery was all the more likely, for primitive weapons were
never fashioned with exactitude. That this asymmetry serves a
useful purpose, therefore, was first revealed by experience. As a
result, however, primitive man began to copy as faithfully as possible
those implements which most perfectly exhibited this characteristic.
Thus, this missile is not a weapon that required exceptional inventive
ability, though, of course, it demanded certain powers of
observation. The characteristics, accordingly, that insured the
survival of the boomerang were discovered accidentally and then
fixed through an attentive regard to those qualities that had once
been found advantageous. Now, can we conceive of the origin of
bow and arrow in an analogous way? Surely this weapon also was
not devised in all its parts at a single time. The man of nature,
pressing his way through the dense underbrush of the forest and
experiencing in person the hard blows of branches that he has bent
back, gains a lively impression of the elastic power of bent wood.
How easily the attention is forced to the observation that this effect
increases when the wood is bent out of its natural shape, appears
strikingly in the case of a kind of bow found in Asia and the Asiatic
islands. The bow is here constructed out of a piece of wood bent by
nature, not in such a way, however, that the natural curve of the
wood forms the curve of the bow, but contrariwise. Thus arises a
reflexive bow, whose elastic power is, of course, considerably
increased. In order that such a bow may be bent back more easily,
some people of a more advanced culture construct it out of several
layers of wood, horn, sinew, or the like. Having first observed the
powerful impulsive force which a rod gains through being bent, it
was a simple matter to render this force permanently available by
bending the rod back and binding its ends together with a cord of
bast, or, if bamboo was used, with strips torn from the bamboo
itself. Thus originated the common form of the bow. Next, it was, of
course, easy to observe that the bowstring thus contrived would
communicate a powerful impetus to a lighter piece of wood placed
against it. In addition to the bow, we then have the arrow, which is
hurled into the distance by the combined propelling power of the
bow and its string. But at this point a new factor appeared, clearly
indicating that several motives generally co-operated in the case of
such so-called primitive inventions. In these inventions nature itself
played no less a part than did the inventive genius of the individual.
The arrow but rarely consists merely of a piece of wood one of
whose ends is somehow pointed or provided with a stone head, or,
at a later period, with an iron head. As is well known, the other end
is feathered, either with genuine bird feathers or, as in the case of
the pygmies of Central Africa, with an imitation of bird feathers
made of palm-leaves. The feathers are usually supposed to have
been added to insure the accurate flight of the arrow. And this
accuracy is, indeed, the resultant effect. As in the case of the
boomerang, however, we must again raise the question: How did
man come to foresee this effect, of whose mechanical conditions he
had, of course, not the slightest knowledge? The solution of this
problem probably lies in the fact of an association of the discharged
arrow with a flying bird that pierces the air by the movement of its
feathers. Thus, in the arrow, man copied the mode of movement of
the bird. He certainly did not copy it, however, with the thought that
he was causing movement in a mechanical way. We must bear in
mind that for primitive man the image of a thing is in reality always
equivalent to the thing itself. Just as he believes that his spirit
resides in his picture, with the result that he is frequently seized with
fright when a painter draws his likeness and carries it away with
him, so also does the feathered arrow become for him a bird. In his
opinion, the qualities of the bird are transferred by force of magic to
the arrow. In this case, indeed, the magical motive is in harmony
with the mechanical effect.
Nature directly supplies primitive man not only with the patterns of
his implements and weapons, but also with those of the vessels
which he uses. Of the primitive tribes none is familiar, at the outset,
with pottery. In its stead, suitable natural objects are utilized for
storing what is gathered. The Negritos of the Philippines, for
example, employ coconut shells. The inland tribes of the Malay
Peninsula use bamboo, whose varying thicknesses, and, particularly,
whose internodes enable it to be converted into the desired vessels
by cutting the stem at the upper end of an internode and
immediately below it, thus securing a vessel with a bottom.
Wherever primitive peoples cut vessels out of wood, as occurs
among the Veddahs and the Bushmen, we may be sure that this
represents a comparatively late acquirement, following upon a
knowledge of metals and the use of stone implements. Primitive
man possesses no vessels for cooking purposes. He prepares his
food directly in the fire or in hot ashes.
We are now confronted by a final and an especially interesting
question of primitive culture, that of the acquisition of fire. This
acquisition made a deep impression on the human mind, and one
whose effects long survived in legend. The totemic age, as we shall
see, is replete with legends of beneficent animals which brought fire
to man. In the heroic age, the fire-bringing animal is displaced by
the fire-bringing hero. We may call to mind Prometheus, who
brought fire from heaven, and by so doing drew upon himself the
vengeance of the gods. Nevertheless, the question concerning the
original production of fire is a very simple one. As in the case of very
many utensils and tools, we must look to natural conditions that
present themselves in the course of experience. Man did not invent
the art of kindling fire; it would be nearer the truth to say that he
found it, inasmuch as he discovered it while making his utensils. In
this connection, particularly, it is highly important to note that the
first age, if we would designate it by its tools, was not an age of
stone but an age of wood. We have already referred to the way in
which bamboo was worked up into vessels for the storing of fruits
and liquids. With a sharp sliver of bamboo, a bamboo-stem is sawed
into pieces in order that its parts may be utilized. If this sawing
occurs during dry weather, the wood is pulverized and the heated
sawdust finally becomes ignited. As soon as it begins to glow, the
worker blows upon it and the fire flames up. This mode of kindling
fire has been called that of sawing, and is probably the oldest in
origin. After fire was thus accidentally produced, it became possible
to kindle it at will, and this developed into a skilful art. At a later
stage, however, there came the further need of drilling holes into
wood. This gave rise to a second method of kindling fire, that of
drilling. A piece of wood is bored through with a sharpened stick of
hard wood, and the same results occur as in the case of the sawing.
The method of drilling is the more effective; it produces fire more
quickly. Nevertheless, both methods are laborious and tedious, and
we cannot blame the savage for regarding as a magician the
European who before his very eyes lights a match by friction.
Because of the difficulty in producing fire, its preservation plays an
important rôle in the life of the savage. When he changes his
dwelling-place, his first consideration, as a rule, is to take with him
some live fire so that he will not be obliged to kindle it anew.
In conclusion, we may supplement these sketches of external culture
by mention of a feature that is particularly characteristic of the
relation of primitive man to his environment. Primitive man lives in
close association with his fellow-tribesmen, but he secludes himself
from other tribes of the neighbourhood. He is led to do so because
they threaten his means of subsistence; indeed, he himself may fall
a prey to them, as do the Pygmies of Central Africa to the
anthropophagic customs of the Monbuttus. And yet, primitive man
early feels the need of such useful articles as he cannot himself
produce but with which he has, in some accidental manner, become
acquainted. This gives rise to what is generally called 'secret barter.'
An illuminating example of this occurs in the records of the Sarasin
cousins as relating to the Veddahs. The Veddah goes by night to the
house of a neighbouring Singhalese smith and there deposits what
he has to offer in barter, such as captured game, ivory, etc. With this
he places a representation of an arrow-head, made of palm-leaves.
The next night he returns and finds real arrows of iron which the
smith has laid out in exchange for the proffered goods. It might be
thought that such a system of barter would imply an excessive
measure of confidence. The smith, however, knows that, should he
take away that which was brought to him without delivering the
arrows, he would himself be struck by an arrow shot from some
sheltered ambush. Thus, many things, especially iron, materials for
clothing, and articles of adornment, come into the possession of
primitive man through secret barter, raising his external culture to a
somewhat higher level.
A retrospective survey of this culture brings to notice especially the
fact that the concept 'primitive' is never valid, as applied to man,
except in a relative sense. Of an absolutely primitive man we know
nothing at all. Moreover, the knowledge of such a being could hardly
render explicable his further development, since he would really
belong to the animal level and therefore to the prehuman stage of
existence. Primitive man is relatively primitive, for, while he does
possess certain beginnings of culture, these are in no respect more
than mere beginnings, all of which are borrowed from nature and
from the direct means of assistance which it offers. It is precisely
these elementary acquisitions, however, that already differentiate
primitive man from the animal. He has the beginnings of a dwelling
and of dress, even though he does no more in either case than
merely to utilize the means which nature offers, or than partly to
imitate and partly to combine these means, as he does in the case
of the leafy wind-break and of the weapons which doubtless
represent the highest achievement of this age—namely, the bow and
arrow. But these are all beginnings which already contain within
themselves the possibilities of higher achievements. The
development of the hut out of the wind-break, of the lance out of
the staff and the arrow, of the woven basket out of the coconut or
the gourd, severally represent easy steps in the advance from nature
to culture. Next there comes the preparation of food by means of
fire. This is closely connected with the discovery of the art of
kindling fire, which, in its turn, was partly an accidental discovery
connected with the manufacture of primitive tools out of wood and
partly a real invention. Thus, the manufacture of tools, on the one
hand, and the kindling of fire, which was connected with it, on the
other, are the two primary features which from early times on
distinguished primitive man from animals. Furthermore, there is the
bow and arrow, which is the first real weapon and differs markedly
from all other implements. Its construction also was dependent upon
the assistance of nature. The fact that this was the only weapon of
primitive society throws an important light on the nature of the
latter. The bow and arrow continued to be used for a long time
afterwards—indeed, even down to the appearance of firearms; it
served not only as a weapon of warfare but also as an implement for
hunting. With it alone, however, no organized strife or warfare of any
sort is possible. While, therefore, it is true that the archer appears
on the earliest monuments of cultural peoples, it is only as the
fellow-combatant of the warrior who is armed with shield and lance.
With lance and shield it is possible to fight in closed ranks. The
archer must fight single-handed. Primitive man, therefore, does not
engage in tribal wars; he is familiar only with the strife of individual
with individual. In fact, wherever the bow and arrow is used
exclusively, open warfare is impossible. With it, primitive man slays
his enemy from behind a sheltering bush. It is thus that the Veddah
of nature serves the cultural Veddah, or the Singhalese who has
deceived him in secret barter, or even the fellow-tribesman who
steals his wife. Just as secret barter is carried on in concealment, so
also is warfare. This, however, indicates that the bow and arrow was
originally intended for hunting and not for warfare. From this
consideration alone it is evident that primitive life was not a war of
all against all, as it was described by Thomas Hobbes. On the
contrary, there doubtless existed a state of peace, interrupted only
occasionally by the strife of individual with individual—a strife that
resulted from a conflict of interests, such as occurred even during
this early period.

3. THE ORIGIN OF MARRIAGE AND THE FAMILY.

That the origin of marriage and the family really constitutes a


problem, long failed to be recognized. Because of the natural
relations of the sexes it was supposed that man lived in a state of
marriage from the very beginning. Furthermore, the monogamous
marriage of the present was projected back into an indefinite past,
where it found final termination in the idea of a primal pair of
ancestors. But, even apart from this mythological belief, there were
also positive grounds for supposing an original state of monogamy.
Do not many animals live in monogamous union? In addition to nest-
building birds, monogamy prevails particularly among mammals,
and, of the latter, among those that have the closest physical
relationship to man. We might cite the gorilla, the primate that most
resembles man, and probably also the chimpanzee, although in this
case we lack positive proof. Why, then, should not man have carried
over monogamous marriage from his animal state into his primitive
culture? This theory, therefore, was regarded as almost self-evident
until after the middle of the last century. But in 1861, a Swiss jurist
and antiquarian, J. Bachofen, published a remarkable work on
"Mother-right." In this book Bachofen attempted to prove the falsity
of the doctrine—previously almost uncontested—that monogamy
was the original form of marriage, and to refute the view, regarded
as equally self-evident, that within this marriage union man held the
supremacy—in brief, the patriarchal theory. Bachofen started with a
discussion of the Lycians as described by Herodotus. According to
this writer, the kinship of the children, among the Lycians, was
determined by the mother, not by the father. The sons and
daughters belonged to the family of the mother, and descent was
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about testbank and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!

ebooksecure.com

You might also like