0% found this document useful (0 votes)
10 views80 pages

17575

The document provides information about various textbooks on data structures and algorithms, primarily focusing on C and C++ programming. It includes details about the authors, ISBNs, and links for downloading the books. Additionally, it outlines a preparation plan for interviews related to data structures and algorithms, emphasizing the importance of understanding algorithms and data structures for computer programming.

Uploaded by

mickobularqr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views80 pages

17575

The document provides information about various textbooks on data structures and algorithms, primarily focusing on C and C++ programming. It includes details about the authors, ISBNs, and links for downloading the books. Additionally, it outlines a preparation plan for interviews related to data structures and algorithms, emphasizing the importance of understanding algorithms and data structures for computer programming.

Uploaded by

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

Problem Solving in Data Structures and

Algorithms Using C 1st Edition by Hemant Jain


ISBN 1540407306 9781540407306 install download

https://ebookball.com/product/problem-solving-in-data-structures-
and-algorithms-using-c-1st-edition-by-hemant-jain-
isbn-1540407306-9781540407306-15866/

Explore and download more ebooks or textbooks


at ebookball.com
Get Your Digital Files Instantly: PDF, ePub, MOBI and More
Quick Digital Downloads: PDF, ePub, MOBI and Other Formats

Problem Solving in Data Structures and Algorithms Using C 1st Edition


by Hemant Jain ISBN 9352655915 9789352655915

https://ebookball.com/product/problem-solving-in-data-structures-
and-algorithms-using-c-1st-edition-by-hemant-jain-
isbn-9352655915-9789352655915-15768/

Data Structures and Problem Solving Using C++ 2nd edition by MALIK
ISBN 0324782012 978-0324782011

https://ebookball.com/product/data-structures-and-problem-
solving-using-c-2nd-edition-by-malik-
isbn-0324782012-978-0324782011-16350/

Data Structures And Problem Solving Using Java 4th Edition by Mark
Weiss 0321541405 9780321541406

https://ebookball.com/product/data-structures-and-problem-
solving-using-java-4th-edition-by-mark-
weiss-0321541405-9780321541406-17186/

Data Structures and Problem Solving Using Java 4th edition by Mark
Allen Weiss ISBN 0321541405 978-0321541406

https://ebookball.com/product/data-structures-and-problem-
solving-using-java-4th-edition-by-mark-allen-weiss-
isbn-0321541405-978-0321541406-16342/
Data Structures and Algorithms in C 1st edition by Adam Drozdek ASIN
B002WLXMBY

https://ebookball.com/product/data-structures-and-algorithms-
in-c-1st-edition-by-adam-drozdek-asin-b002wlxmby-25076/

Data Structures Algorithms and Applications in C++ 1st edition by Adam


Drozdek ISBN 1133608426 9781133608424

https://ebookball.com/product/data-structures-algorithms-and-
applications-in-c-1st-edition-by-adam-drozdek-
isbn-1133608426-9781133608424-17250/

Principles of Data Structures Using C and C 1st Edition by Vinu Das


ISBN 8122418589 9788122418583

https://ebookball.com/product/principles-of-data-structures-
using-c-and-c-1st-edition-by-vinu-das-
isbn-8122418589-9788122418583-15766/

Data Structures Algorithms and Applications in C With Microsoft


Compiler 2nd Edition by Sartaj Sahni ISBN 0929306325 9780929306322

https://ebookball.com/product/data-structures-algorithms-and-
applications-in-c-with-microsoft-compiler-2nd-edition-by-sartaj-
sahni-isbn-0929306325-9780929306322-15764/

Data Structures Algorithms and Applications in C++ With Microsoft


Compiler 1st edition by Sartaj Sahni ISBN 007236226X 978-0072362268

https://ebookball.com/product/data-structures-algorithms-and-
applications-in-c-with-microsoft-compiler-1st-edition-by-sartaj-
sahni-isbn-007236226x-978-0072362268-16394/
Problem Solving in
Data Structures &
Algorithms Using
C++
First Edition

By Hemant Jain
Problems Solving in Data Structures & Algorithms Using C++
HEMANT JAIN

Copyright © 2016 by HEMANT JAIN. All Right Reserved.

No part of this publication may be reproduced, distributed, or transmitted in any


form or by any means, including photocopying, recording, or other electronic or
mechanical methods, or by any information storage and retrieval system without
the prior written permission of the author, except in the case of very brief
quotations embodied in critical reviews and certain other non-commercial uses
permitted by copyright law.
ACKNOWLEDGEMENT
The author is very grateful to GOD ALMIGHTY for his grace and blessing.

Deepest gratitude for the help and support of my brother Dr. Sumant Jain. This
book would not have been possible without the support and encouragement he
provided.

I would like to express profound gratitude to my guide/ my friend Naveen


Kaushik for his invaluable encouragement, supervision and useful suggestion
throughout this book writing work. His support and continuous guidance enable
me to complete my work successfully.

Last but not least, I am thankful to Anil Berry and Others who helped me
directly or indirectly in completing this book.

Hemant Jain
TABLE OF CONTENTS
TABLE OF CONTENTS
TABLE OF CONTENTS
CHAPTER 0: HOW TO USE THIS BOOK
WHAT THIS BOOK IS ABOUT
PREPARATION PLANS
SUMMARY
CHAPTER 1: INTRODUCTION - PROGRAMMING OVERVIEW
INTRODUCTION
FIRST C++ PROGRAM
OBJECT
VARIABLE
PARAMETER PASSING, CALL BY VALUE
PARAMETER PASSING, CALL BY REFERENCE
PARAMETER PASSING, CALL BY POINTER
KINDS OF VARIABLES
METHODS
ACCESS MODIFIERS
ABSTRACT CLASS
RELATIONSHIP
GENERAL PROTOTYPE OF A CLASS
NESTED CLASS
ENUMS
CONSTANTS
CONDITIONS AND LOOPS
ARRAY
VECTOR
ARRAY INTERVIEW QUESTIONS
CONCEPT OF STACK
SYSTEM STACK AND METHOD CALLS
RECURSIVE FUNCTION
EXERCISES
CHAPTER 2: ALGORITHMS ANALYSIS
INTRODUCTION
ASYMPTOTIC ANALYSIS
BIG-O NOTATION
OMEGA-Ω NOTATION
THETA-Θ NOTATION
COMPLEXITY ANALYSIS OF ALGORITHMS
TIME COMPLEXITY ORDER
DERIVING THE RUNTIME FUNCTION OF AN ALGORITHM
TIME COMPLEXITY EXAMPLES
MASTER THEOREM
MODIFIED MASTER THEOREM
EXERCISE
CHAPTER 3: APPROACH TO SOLVE ALGORITHM DESIGN
PROBLEMS
INTRODUCTION
CONSTRAINTS
IDEA GENERATION
COMPLEXITIES
CODING
TESTING
EXAMPLE
SUMMARY
CHAPTER 4: ABSTRACT DATA TYPE & C++ COLLECTIONS
ABSTRACT DATA TYPE (ADT)
DATA-STRUCTURE
C++ COLLECTION FRAMEWORK
ARRAY
LINKED LIST
STACK
QUEUE
TREES
BINARY TREE
BINARY SEARCH TREES (BST)
PRIORITY QUEUE (HEAP)
HASH-TABLE
DICTIONARY / SYMBOL TABLE
GRAPHS
GRAPH ALGORITHMS
SORTING ALGORITHMS
COUNTING SORT
END NOTE
CHAPTER 5: SEARCHING
INTRODUCTION
WHY SEARCHING?
DIFFERENT SEARCHING ALGORITHMS
LINEAR SEARCH – UNSORTED INPUT
LINEAR SEARCH – SORTED
BINARY SEARCH
STRING SEARCHING ALGORITHMS
HASHING AND SYMBOL TABLES
HOW SORTING IS USEFUL IN SELECTION ALGORITHM?
PROBLEMS IN SEARCHING
EXERCISE
CHAPTER 6: SORTING
INTRODUCTION
TYPE OF SORTING
BUBBLE-SORT
MODIFIED (IMPROVED) BUBBLE-SORT
INSERTION-SORT
SELECTION-SORT
MERGE-SORT
QUICK-SORT
QUICK SELECT
BUCKET SORT
GENERALIZED BUCKET SORT
HEAP-SORT
TREE SORTING
EXTERNAL SORT (EXTERNAL MERGE-SORT)
COMPARISONS OF THE VARIOUS SORTING ALGORITHMS.
SELECTION OF BEST SORTING ALGORITHM
EXERCISE
CHAPTER 7: LINKED LIST
INTRODUCTION
LINKED LIST
TYPES OF LINKED LIST
SINGLY LINKED LIST
DOUBLY LINKED LIST
CIRCULAR LINKED LIST
DOUBLY CIRCULAR LIST
EXERCISE
CHAPTER 8: STACK
INTRODUCTION
THE STACK ABSTRACT DATA TYPE
STACK USING ARRAY
STACK USING ARRAY (GROWING-REDUCING CAPACITY
IMPLEMENTATION)
STACK USING LINKED LIST
PROBLEMS IN STACK
PROS AND CONS OF ARRAY AND LINKED LIST IMPLEMENTATION
OF STACK.
USES OF STACK
EXERCISE
CHAPTER 9: QUEUE
INTRODUCTION
THE QUEUE ABSTRACT DATA TYPE
QUEUE USING ARRAY
QUEUE USING LINKED LIST
PROBLEMS IN QUEUE
EXERCISE
CHAPTER 10: TREE
INTRODUCTION
TERMINOLOGY IN TREE
BINARY TREE
TYPES OF BINARY TREES
PROBLEMS IN BINARY TREE
BINARY SEARCH TREE (BST)
PROBLEMS IN BINARY SEARCH TREE (BST)
EXERCISE
CHAPTER 11: PRIORITY QUEUE
INTRODUCTION
TYPES OF HEAP
HEAP ADT OPERATIONS
OPERATION ON HEAP
HEAP-SORT
USES OF HEAP
PROBLEMS IN HEAP
EXERCISE
CHAPTER 12: HASH-TABLE
INTRODUCTION
HASH-TABLE
HASHING WITH OPEN ADDRESSING
HASHING WITH SEPARATE CHAINING
COUNT MAP
PROBLEMS IN HASHING
EXERCISE
CHAPTER 13: GRAPHS
INTRODUCTION
GRAPH REPRESENTATION
ADJACENCY MATRIX
ADJACENCY LIST
GRAPH TRAVERSALS
DEPTH FIRST TRAVERSAL
BREADTH FIRST TRAVERSAL
PROBLEMS IN GRAPH
DIRECTED ACYCLIC GRAPH
TOPOLOGICAL SORT
MINIMUM SPANNING TREES (MST)
SHORTEST PATH ALGORITHMS IN GRAPH
EXERCISE
CHAPTER 14: STRING ALGORITHMS
INTRODUCTION
STRING MATCHING
DICTIONARY / SYMBOL TABLE
PROBLEMS IN STRING
EXERCISE
CHAPTER 15: ALGORITHM DESIGN TECHNIQUES
INTRODUCTION
BRUTE FORCE ALGORITHM
GREEDY ALGORITHM
DIVIDE-AND-CONQUER, DECREASE-AND-CONQUER
DYNAMIC PROGRAMMING
REDUCTION / TRANSFORM-AND-CONQUER
BACKTRACKING
BRANCH-AND-BOUND
A* ALGORITHM
CONCLUSION
CHAPTER 16: BRUTE FORCE ALGORITHM
INTRODUCTION
PROBLEMS IN BRUTE FORCE ALGORITHM
CONCLUSION
CHAPTER 17: GREEDY ALGORITHM
INTRODUCTION
PROBLEMS ON GREEDY ALGORITHM
CHAPTER 18: DIVIDE-AND-CONQUER, DECREASE-AND-CONQUER
INTRODUCTION
GENERAL DIVIDE-AND-CONQUER RECURRENCE
MASTER THEOREM
PROBLEMS ON DIVIDE-AND-CONQUER ALGORITHM
CHAPTER 19: DYNAMIC PROGRAMMING
INTRODUCTION
PROBLEMS ON DYNAMIC PROGRAMMING ALGORITHM
CHAPTER 20: BACKTRACKING AND BRANCH-AND-BOUND
INTRODUCTION
PROBLEMS ON BACKTRACKING ALGORITHM
CHAPTER 21: COMPLEXITY THEORY AND NP COMPLETENESS
INTRODUCTION
DECISION PROBLEM
COMPLEXITY CLASSES
CLASS P PROBLEMS
CLASS NP PROBLEMS
CLASS CO-NP
NP–HARD:
NP–COMPLETE PROBLEMS
REDUCTION
END NOTE
CHAPTER 22: INTERVIEW STRATEGY
INTRODUCTION
RESUME
NONTECHNICAL QUESTIONS
TECHNICAL QUESTIONS
CHAPTER 23: SYSTEM DESIGN
SYSTEM DESIGN
SYSTEM DESIGN PROCESS
SCALABILITY THEORY
DESIGN SIMPLIFIED FACEBOOK
DESIGN A SHORTENING SERVICE LIKE BITLY
STOCK QUERY SERVER
DESIGN A BASIC SEARCH ENGINE DATABASE
DUPLICATE INTEGER IN MILLIONS OF DOCUMENTS
ZOMATO
YOUTUBE
DESIGN IRCTC
ALARM CLOCK
DESIGN FOR ELEVATOR OF A BUILDING
VALET PARKING SYSTEM
OO DESIGN FOR A MCDONALDS SHOP
OBJECT ORIENTED DESIGN FOR A RESTAURANT
OBJECT ORIENTED DESIGN FOR A LIBRARY SYSTEM
SUGGEST A SHORTEST PATH
EXERCISE
APPENDIX
APPENDIX A
INDEX
CHAPTER 0: HOW TO USE THIS
BOOK
What this book is about
This book is about usage of data structures and algorithms in computer
programming. Data structures are the ways in which data is arranged in
computers memory. Algorithms are set of instructions to solve some problem by
manipulating these data structures.

Designing an efficient algorithm to solve a computer science problem is a skill


of Computer programmer. This is the skill which tech companies like Google,
Amazon, Microsoft, Facebook and many others are looking for in an interview.
Once we are comfortable with a programming language, the next step is to learn
how to write efficient algorithms.

This book assumes that you are a C++ language developer. You are not an expert
in C++ language, but you are well familiar with concepts of pointers, references,
functions, arrays and recursion. At the start of this book, we will be revising the
C++ language fundamentals that will be used throughout this book. In the
chapter 1 we will be looking into some of the problems in arrays and recursion
too.

Then in the coming chapter we will be looking into Complexity Analysis.


Followed by the various data structures and their algorithms. Will look into a
Linked-List, Stack, Queue, Trees, Heap, Hash-Table and Graphs. We will also be
looking into Sorting, Searching techniques.

And we will be looking into algorithm analysis of various algorithm techniques,


such as Brute-Force algorithms, Greedy algorithms, Divide and Conquer
algorithms, Dynamic Programming, Reduction and Back-Tracking.

In the end, we will be looking into System Design that will give a systematic
approach to solve the design problems in an Interview.
Preparation Plans
Given the limited time you have before your next interview, it is important to
have a solid preparation plan. The preparation plan depends upon the time and
which companies you are planning to target. Below are the three-preparation
plan for 1 Month, 3 Month and 5 Month durations.

1 Month Preparation Plans


Below is a list of topics and approximate time user need to take to finish these
topics. These are the most important chapters that must to be prepared before
appearing for an interview.

This plan should be used when you have a small time before an interview. These
chapters cover 90% of data structures and algorithm interview questions. In this
plan since we are reading about the various ADT and C++ collections in chapter
4 so we can use these datatype easily without knowing the internal details how
they are implemented.
Chapter 24 is for system design, you must read this chapter if you are three or
more years of experienced. Anyway, reading this chapter will give the reader a
broader perspective of various designs.

Time Chapters Explanation


Week 1 Chapter 1: Introduction - You will get a basic understanding of
Programming Overview how to find complexity of a solution.
Chapter 2: Algorithms Analysis You will know how to handle new
Chapter 3: Approach To Solve problems. You will read about a variety
Algorithm Design Problems of datatypes and their uses.
Chapter 4: Abstract Data Type &
C++ Collections
Week 2 Chapter 5: Searching Searching, Sorting and String algorithm
Chapter 6: Sorting consists of a major portion of the
Chapter 14: String Algorithms interviews.
Week 3 Chapter 7: Linked List Linked list, Stack and Queue are one of
Chapter 8: Stack the favorites in an interview.
Chapter 9: Queue
Week 4 Chapter 10: Tree This portion you will read about Trees
Chapter 23: Interview Strategy and System Design. You are good to go
Chapter 24: System Design for interviews. Best of luck.

3 Month Preparation Plan


This plan should be used when you have some time to prepare for an interview.
This preparation plan includes nearly everything in this book except various
algorithm techniques. Algorithm problems that are based on dynamic
programming divide & conquer etc. Which are asked in vary specific companies
like Google, Facebook, etc. Therefore, until you are planning to face interview
with them you can park these topics for some time and focus on the rest of the
topics.

Again, same thing here with system design problems, the more experience you
are, the more important this chapter becomes. However, if you are a fresher from
college, then also you should read this chapter.

Time Chapters Explanation


Week 1 Chapter 1: Introduction - You will get a basic understanding of
Programming Overview how to find complexity of a solution.
Chapter 2: Algorithms You will know how to handle new
Analysis problems. You will read about a
Chapter 3: Approach To Solve variety of datatypes and their uses.
Algorithm Design Problems
Chapter 4: Abstract Data Type &
C++ Collections
Week 2 Chapter 5: Searching Searching, sorting and string algorithm
& Week Chapter 6: Sorting consists of a major portion of the
3 Chapter 14: String Algorithms interviews.
Week 4 Chapter 7: Linked List Linked list, Stack and Queue are one
& Week Chapter 8: Stack of the favorites in an interview.
5 Chapter 9: Queue
Week 6 Chapter 10: Tree This portion you will read about trees
& Week Chapter 11: Heap and heap data structures.
7
Week 8 Chapter 12: Hash-Table Hash-Table is used throughout this
& Week Chapter 13: Graphs book in various places, but now it’s
9 time to understand how Hash-Table
are actually implemented.
Graphs are used to propose a solution
many real life problems.
Week 10 Chapter 23: Interview Strategy Interview strategy and system design
Chapter 24: System Design chapter are the final chapters of this
course.
Week 11 Revision of the chapters listed At this time, you need to revise all the
& Week above. chapters that we have seen in this
12 book. Whatever is left needs to be
completed and the exercise that may
be left needing to be solved in this
period of time.

5 Month Preparation Plan


In this preparation plan is made on top of 3-month plan. In this plan, the students
should look for algorithm design chapters. In addition, in the rest of the time
they need to practice more and more from www.topcoder.com and other
resources. If you are targeting google, Facebook, etc., Then it is highly
recommended to join topcoder and practice as much as possible.

Time Chapters Explanation


Week 1 Chapter 1: Introduction - You will get a basic understanding of how to
Week 2 Programming Overview find complexity of a solution. You will know
Chapter 2: Algorithms how to handle new problems. You will read
Analysis about a variety of datatypes and their uses.
Chapter 3: Approach To
Solve Algorithm Design
Problems
Chapter 4: Abstract Data
Type & C++ Collections
Week 3 Chapter 5: Searching Searching, sorting and string algorithm
Week 4 Chapter 6: Sorting consists of a major portion of the interviews
Week 5 Chapter 14: String
Algorithms
Week 6 Chapter 7: Linked List Linked list, Stack and Queue are one of the
Week 7 Chapter 8: Stack favorites in an interview
Week 8 Chapter 9: Queue
Week 9 Chapter 10: Tree This portion you will read about trees and
Week 10 Chapter 11: Heap priority queue
Week 11 Chapter 12: Hash-Table Hash-Table is used throughout this book in
Week 12 Chapter 13: Graphs various places, but now it’s time to
understand how Hash-Table are actually
implemented.
Graphs are used to propose a solution many
real life problems
Week 13 Chapter 15: Algorithm These chapters contain various algorithms
Week 14 Design Techniques types and their usage. Once the user is
Week 15 Chapter 16: Brute Force familiar with most of this algorithm. Then
Week 16 Chapter 17: Greedy the next step is to start solving topcoder
Algorithm problems from topcode
Chapter 18: Divide-And-
Conquer, Decrease-And-
Conquer
Chapter 19: Dynamic
Programming
Chapter 20: Backtracking
And Branch-And-Bound
Chapter 21: Complexity
Theory And Np
Completeness
Week 17 Chapter 22: Interview Interview strategy and system design chapter
Week 18 Strategy are the final chapters of this course
Chapter 23: System Design
Week 19 Revision of the chapters At this time, you need to revise all the
Week 20 listed above chapters that we have seen in this book.
Whatever is left needs to be completed and
the exercise that may be left needing to be
solved in this period
Summary
These are few preparation plans that can be followed to complete this book there
by preparing for the interview. It is highly recommended that the user should
read the problem statement first, then he should try to solve the problems by
himself and then only he should look into the solution to find the approach of the
book. Practicing more and more problems will increase your thinking capacity
and you will be able to handle new problems in an interview. System design is a
topic that is not asked much from a fresher from college, but as you gain
experience its importance increase. We will recommend practicing all the
problems given in this book, then solve more and more problems from online
resources like www.topcoder.com, www.careercup.com, www.geekforgeek.com
etc.
CHAPTER 1: INTRODUCTION -
PROGRAMMING OVERVIEW
Introduction
This chapter emphasizes on brush up of the fundamentals of the C++
Programming language. It will talk about variables, pointers, references, classes,
loops, recursion, arrays etc. We assume that the reader is familiar with the syntax
of the C++ programming language and knows the basics of Object-Orientation.
First C++ Program

Example 1.1:
#include <iostream>

int main(int argc, char* argv[])


{
//Single Line comment.

/*
Multiple line comments.
*/

std::cout << "Hello, World!" << std::endl;


return 0;
}

It is tradition to discuss a HelloWorld program in the start which will print the
phrase “Hello, World!” to the output screen. So let us start discussing it. This is a
small program but it contains many common features of all the C++ programs.

1. This program begins with “#include <iostream>”:


a. This tells the compiler that we are going to use the functions defined
in iostream file. Cpp language provide a number of predefined files,
which contain functions that are commonly used by programmer.
For example std::cout is defined inside iostream file which will be
used to print “Hello, World!” to the output screen.
2. Next comes the method “int main(int argc, char* argv[])”:
a. A method is a set of statements that are executed to give desire
result.
b. main() is a special method of a class this is the entry point of the
application.
c. The int keyword means that this method is going to return an integer
value in our case it is 0.
3. Next are the comments, which are for readability of the program and are
ignored by the compiler.
a. A single line comment begins with two forward slash //
b. A multiline comment begins with /* and ends with */.
4. “std::cout << "Hello, World!" << std::endl;”, is a system provided
operator(object) which will print “Hello, World! ” to the standard output
and will print next line char in the end.

5. In the end there is a “return 0;” which will give return value to the caller
of the main function. Return statement is a way to pass the return value to
the caller of the function.
Object
An Object is an entity with state and behavior. A cat, a dog, a bulb etc are all
examples of objects. For example a bulb have two states (on, off) and the two
behaviors (turn on, turn off).

Software objects are just like real world objects. They have state in the form of
member variables called fields (isOn) and they expose behavior in the form of
member functions called methods (turn on, turn off).

Hiding internal details (state) of the object and allowing all the actions to be
performed over the objects using methods is known has data-encapsulation.

A Class is a prototype (blueprint) of objects. An object is an instance of a class.


Human is a class of living being and a person named John is an instance of
human class.

Example 1.2:
class Bulb
{
private:
// Instance Variables
bool isOn;

public:
// Constructor
Bulb();

// Instance Method
virtual void turnOn();

// Instance Method
virtual void turnOff();

// Instance Method
virtual bool isOnFun();
};

In this example, we have a class name Bulb. It has a member variable isOn,
which indicates its state that the bulb is on or off. It has two methods turnOn()
and turnoff() which will change the state of the object from off to on and vice
versa.
Variable
"Variables" are simply storage locations for data. For every variable, some
memory is allocated. The size of this memory depends on the type of the
variable.

Example 1.3:
void variableExample()
{
int var1, var2, var3;
var1 = 100;
var2 = 200;
var3 = var1 + var2;
std::cout << "Adding " << var1 << " and " << var2 << " will give " << var3 << std::endl;
}

Analysis:
· Memory is allocated for variables var1, var2 and var3. Whenever we
declare a variable, then memory is allocated for storing the value in the
variable. In our example, 4 bytes are allocated for each of the variable.
· Value 100 is stored in variable var1 and value 200 is stored in variable
var2.
· Value of var1 and var2 is added and stored in var3.
· Finally, the value of var1, var2 and var3 is printed to screen using
std::cout.
Parameter passing, Call by value
Arguments can be passed from one method to other using parameters. By default
all, the variables, which are passed as parameters, are passed-by-value. That
means a separate copy is created inside the called method and no changes done
inside called method will reflect in calling method.

Example 1.4:
void incrementPassByValue(int var)
{
var++;
}

int main()
{
int i = 10;
std::cout << "Value of i before increment is : " << i << std::endl;
incrementPassByValue(i);
std::cout << "Value of i after increment is : " << i << std::endl;
}

Output:
Value of i before increment is : 10
Value of i after increment is : 10

Analysis:
· Variable ”i” is declared and the value 10 is initialized to it.
· Value of ”i” is printed.
· Increment method is called. When a method is called the value of the
parameter is copied into another variable of the called method. Flow of
control goes to increase() function.
· Value of var is incremented by 1. However, remember, it is just a copy
inside the increment method.
· When the method exits, the value of ”i” is still 10.

Points to remember:
1. Pass by value just creates a copy of variable.
2. Pass by value, value before and after the method call remain same.
Parameter passing, Call by Reference
If you need to change the value of the parameter inside the method, then you
should use call by reference. C++ language by default passes by value.
Therefore, to make it happen, you need to pass by reference by using “&”
operator. The variable inside the called function also refer to the same variable
inside the calling function. When the value of reference variable is changed then
the original variable value also change.

Example 1.5:
void incrementPassByReference(int& var)
{
var++;
}

int main()
{
int i = 10;
std::cout << "Value of i before increment is : " << i << std::endl;
incrementPassByReference(i);
std::cout << "Value of i after increment is : " << i << std::endl;
}

Output:
Value of i before increment is : 10
Value of i after increment is : 11

Analysis: Variable “i” is passed as pass by reference, so variable “i” inside


calling function and variable “var” inside called function are the same. So value
of var changed inside called function will also be reflected into the variable “i”
inside calling function.
Parameter passing, Call by Pointer
When we pass address of variable inside calling function to the called function
then the changes done inside called function is also reflected inside calling
function.

Example 1.6:
void incrementPassByPointer(int* ptr)
{
(*ptr)++;
}

int main()
{
int i = 10;
std::cout << "Value of i before increment is : " << i << std::endl;
incrementPassByPointer(&i);
std::cout << "Value of i after increment is : " << i << std::endl;
}

Output:
Value of i before increment is : 10
Value of i after increment is : 11

Analysis: We are passing address of a variable inside calling function to the


called function. Moreover, modifying the value at that address so the change
done is reflected to the calling function variable too.
Kinds of Variables
The C++ programming language defines three kinds of variables:
1. Instance Variables (Non-Static): They are instance variables so they are
unique to each instance/object of a class.
2. Class Variables (Static): A class variable is any field with
the static modifier. These variables are linked with the class not with the
objects of the class. There is exactly one copy of these variables regardless of
how many instances of the class are created.
3. Local Variables: the temporary variables in a method are called local
variables. The local variables are only visible to the method in which they are
declared. The parameters that are passed to the methods are also local
variables of the called method.

Example 1.7:
class Bulb
{
private:
// Class Variables
static int TotalBulbCount;

// Instance Variables
bool isOn;

public:
// Constructor
Bulb();

// Class Method
static int getBulbCount();

// Instance Method
virtual void turnOn();

// Instance Method
virtual void turnOff();

// Instance Method
virtual bool isOnFun();
};

Bulb::Bulb()
{
isOn = false;
TotalBulbCount++;
}

int Bulb::getBulbCount()
{
return TotalBulbCount;
}

void Bulb::turnOn()
{
isOn = true;
}

void Bulb::turnOff()
{
isOn = false;
}
bool Bulb::isOnFun()
{
return isOn;
}

Analysis: isOn is an instance variable that is separate for each object. Each bulb
has its state of on or off. However, the total number of bulb is property of the
whole class, which is the total number of objects of type bulb created. The
TotalBulbCount is a class variable and getBulbCount is class method.
Methods
There are four types of methods. Class Methods, Instance Methods and
Constructors. By default, all the methods are instance methods.
Class Methods (Static): The static modifier is used to create class methods.
Class methods with static modifier with them should be invoked with the class
name without the need of creating even a single instance of the class

Instance Methods (Non-Static): These methods can only be invoked over an


instance of the class.

Some points regarding Instance methods and Class methods:


1. Instance methods can access other instance methods and instance variables
directly.
2. Instance methods can access class methods and variables directly.
3. Class methods can access other class methods and class variables directly.
4. Class methods cannot access instance methods and instance variables
directly. To access instance variable and methods they need to create and
instance (object) of class.
5. The special keyword “this” is valid only inside instance methods (and invalid
inside class methods) as “this“ refers to the current instance.

Constructor: It is a special kind of method, which is invoked over objects when


they are created. Constructor methods have the same name as the class.
Constructor method is used to initialize the various fields of the object. For the
class that does not have constructors, C++ language provides default
constructors for them.

Distructor: It is a special kind of method, which is invoked over object when


they are destroyed. Distructor method are named “~” added by the name of the
class. Distructor method is used to do the clean-up of the memory contained in
the object. For the class that does not have Distructor C++ language provide
default Distructor for it.
Access Modifiers
Access modifiers are used to set the visibility level to the class, variables and
methods. C++ provide four types access modifiers: default, public, protected,
private.
1. Private modifier has visibility only within its own class.
2. Public modifier has visibility to all the classes in the package.
3. Protected modifier has visibility within its own class and the subclasses its
own class.
Abstract class
Objects define their interface as the interaction with the outside world. For
example, in the bulb case switch is the interface between you and the bulb. You
press the button turn on and the bulb start glowing. C++ does not have any
interface keyword, it just define some functions as abstract function by making it
“= 0” thereby making the whole class abstract.

Example 1.8:
class BulbInterface
{
public:
virtual void turnOn() = 0;
virtual void turnOff() = 0;
virtual bool isOnFun() = 0;
};

// implements BulbInterface
class Bulb : public BulbInterface
{
private:
// Instance Variables
bool isOn;

public:
// Constructor
Bulb();

// Instance Method
virtual void turnOn();

// Instance Method
virtual void turnOff();

// Instance Method
virtual bool isOnFun();

};

int main()
{
Bulb b;
std::cout << "bulb is on return : " << b.isOnFun() << std::endl;
b.turnOn();
std::cout << "bulb is on return : " << b.isOnFun() << std::endl;
return 0;
}
Analysis:
In this example, BulbInterface is the interface of Bulb class. Bulb class needs to
implement all the methods of BulbInterface to make itself a concrete class. A
concrete class is a class whole object or instance can be created.

An abstract method is a method which does not have a definition. Such methods
are declared with abstract keyword.

A class which has at least one abstract method need to be declared as abstract.
We cannot create objects of an abstract class. (A class which does not have any
abstract method can also be declared as abstract to prevent its object creation.).

Example 1.9:
//Abstract Class
class Shape
{
public:
// Abstract Method
virtual double area() = 0;

// Abstract Method
virtual double perimeter() = 0;
};

Shape is an abstract class. And its instance cannot be created. Those classes,
which extend it, need to implement these two functions to become concrete class
whose instances can be created.

class Circle : public Shape


{
private:
double radius = 0;
public:
Circle();

Circle(double r);

virtual void setRadius(double r);

virtual double area() override;

virtual double perimeter() override;


};

Circle::Circle() :
Circle(1)
{
}

Circle::Circle(double r)
{
radius = r;
}

void Circle::setRadius(double r)
{
radius = r;
}

double Circle::area()
{
return M_PI * std::pow(radius, 2);
}

double Circle::perimeter()
{
return 2 * M_PI * radius;
}

Circle is a class which extends shape class and implement area() and perimeter()
methods.

class Rectangle : public Shape


{

private:
double width = 0, length = 0;

public:
Rectangle();

Rectangle(double w, double l);


virtual void setWidth(double w);

virtual void setLength(double l);

virtual double area() override;

virtual double perimeter() override;


};

Rectangle::Rectangle() :
Rectangle(1, 1)
{}

Rectangle::Rectangle(double w, double l)
{
width = w;
length = l;
}

void Rectangle::setWidth(double w)
{
width = w;
}

void Rectangle::setLength(double l)
{
length = l;
}

double Rectangle::area()
{
return width * length; // Area = width * length
}

double Rectangle::perimeter()
{
return 2 * (width + length); // Perimeter = 2(width + length)
}

Same as Circle class, Rectangle class also extends Shape class and implements
its abstract functions.
#include "Shape.h"
#include "Rectangle.h"
#include "Circle.h"

int main()
{
double width = 2, length = 3;
Shape *rectangle = new Rectangle(width, length);
std::cout << "Rectangle width: " << width << " and length: " << length << " Area: " << rectangle-
>area() << " Perimeter: " << rectangle->perimeter() << std::endl;
double radius = 10;
Shape *circle = new Circle(radius);
std::cout << "Circle radius: " << radius << " Area: " << circle->area() << " Perimeter: " << circle-
>perimeter() << std::endl;
return 0;
}

Analysis: Shape demo creates an instance of the Rectangle and the Circle class
and assign it to a pointer of type Shape. Finally area() and perimeter() functions
are called over instances
Relationship

These various relationships exist between two classes:


1. Dependency: Objects of one-class use objects of another class
temporarily. When a class creates an instance of another class inside its
member method and use it and when the method exits, then the instance of
the other class is deleted.
2. Association: Objects of one class work with objects of another class for
some amount of time. The association is of two kinds - Aggregation and
Composition.
3. Aggregation: One class object share a pointer to objects of another class.
When a class stores the pointer of another class inside it. Just a pointer is
kept inside the class.
4. Composition: One class contains objects of another class. In
Composition, the containing object is responsible for the creation and
deletion of the contained object.
5. Inheritance: One class is a sub-type of another class. Inheritance is a
straightforward relationship to explain the parent-child relationship.

Example 1.10: AdvanceBulb is sub-class of Bulb class. Demonstrating


Inheritance.
class AdvanceBulb : public Bulb
{
private:
// Instance Variables
int intensity;

public:
AdvanceBulb();

// Instance Method
virtual void setIntersity(int i);

// Instance Method
virtual int getIntersity();
};

AdvanceBulb::AdvanceBulb()
{
intensity = 0;
}
void AdvanceBulb::setIntersity(int i)
{
intensity = i;
}
int AdvanceBulb::getIntersity()
{
return intensity;
}

Analysis: In our example, AdvanceBulb is a sub-class of Bulb. When an object


of AdvanceBulb is created, all public and protected methods of Bulb class are
also accessible to it.
General Prototype of a Class

Example 1.11:
class ChildClass : [public/protected/private] ParentClass
{
private:
// private fields and methods.

protected:
// private fields and methods.

public:
// private fields and methods.
};

A ChildClass inherited from ParentClass and implements SomeInterface.


Nested Class
A class within another class is called a nested class.

Compelling reasons for using nested classes include the following:


1. It is a way of logically grouping classes that are only used in one place: If
a class is useful to only one other class, then it is logical to embed it in that
class and keep the two together. Nesting such "helper classes" makes their
package more streamlined.
2. It increases encapsulation: Consider two top-level classes, A and B, where
B needs access to members of A that would otherwise be declared private. By
hiding class B within class A, A's members can be declared private and B can
access them. In addition, B itself can be hidden from the outside world.
3. It can lead to more readable and maintainable code: Nesting small classes
within top-level classes places the code closer to where it is used.

A nested class has an independent set of modifiers from the outer class. Visibility
modifiers (public, private and protected) effect whether the nested class
definition is accessible beyond the outer class definition. For example, a private
nested class can be used by the outer class, but by no other classes.

Example 1.12: Demonstrating Nested Class


class OuterClass
{
private:
class NestedClass
{
// NestedClass fields and methods.
};
// OuterClass fields and methods.
};

Let us take example of LinkedList and Tree class. Both the linked list and tree
have nodes to store new element. Both the linked list and tree have their nodes
different, so it is best to declare their corresponding nodes class inside their own
class to prevent name conflict and increase encapsulation.

Example 1.13:
class LinkedList
{

private:
class Node
{
private:
int value;
Node *next;
// Nested Class Node other fields and methods.

};

Node *head;
int size;
// LinkedList Class other fields and methods.
};

class Tree
{
private:
class Node
{
private:
int value = 0;
Node *lChild;
Node *rChild;
// Nested Class Node other fields and methods.
};

Node *root;
// Tree Class other fields and methods.
};
Enums
Enums restrict a variable to have one of the few predefined values.

Example 1.14:
enum class BulbSize
{
SMALL,
MEDIUM,
LARGE
};

class Bulb
{
private:
// Instance Variables
BulbSize size;
public:
// Instance Method
BulbSize getBulfSize()
{
return size;
}
// Instance Method
void setBulbSize(BulbSize s)
{
size = s;
}
//Other bulb class fields and methods.
};

int main()
{
Bulb b;
b.setBulbSize(BulbSize::MEDIUM);
std::cout << "Bulb Size :" << (int)b.getBulfSize() << std::endl;
return 0;
}

Analysis: In the above code, we made some change to Bulb class. It has one
more field size and size is of type enum BulbSize. And the allowed values of the
size are SMALL, MEDIUM and LARGE.
Constants
Constants are defined by using const modifier. The const modifier indicates that
the value of this field cannot be changed.

For example, the following variable declaration defines a constant named PI,
whose value approximates pi.
const double PI = 3.141592653589793;

Another example, in this we had created a constant of string type.


const std::string text = "Hello, World!";
Conditions and Loops

IF Condition
If condition consists of a Boolean condition followed by one or more statements.
It allows you to take different paths of logic, depending on a given Boolean
condition.

if (boolean_expression)
{
// statements
}

If statement can be followed by else statements and an optional else statement


which is executed when the Boolean condition is false.
if(boolean_expression)
{
// if condition statements boolean condition true
}
else
{
// else condition statements, boolean condition false
}

While Loop
A while-loop is used to repeatedly execute some block of code as long as a given
condition is true.
Example 1.15:
int main()
{
std::vector<int> numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int sum = 0;
int i = 0;
while (i < numbers.size())
{
sum += numbers[i];
i++;
}
std::cout << "Sum is :: " << sum << std::endl;
return 0;
}

Analysis:
All the variables stored in array are added to the sum variable one by one in a
while loop.

Do..While Loop
A do..while-loop is similar to while-loop, but the only difference is that the
conditional code is executed before the test condition. do..while-loop is used
where you want to execute some conditional code at least once.
Example 1.16:
int main()
{
std::vector<int> numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int sum = 0;
int i = 0;
do {
sum += numbers[i];
i++;
} while (i < numbers.size());
std::cout << "Sum is :: " << sum << std::endl;
return 0;
}

For Loop
For loop is just another loop in which initialization, condition check and
increment are bundled together.
for ( initialization; condition; increment )
{
statements
}
Example 1.17:
int main()
{
std::vector<int> numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int sum = 0;
for (int i = 0; i < numbers.size(); i++)
{
sum += numbers[i];
}
std::cout << "Sum is :: " << sum << std::endl;
return 0;
}

ForEach Loop
For loop works well with basic types, but it does not handle collections objects
well. For this, an alternate syntax foreach loop is provided. C++ does not have
keyword foreach it uses for keyword.

for ( declaration : collection / array )


{
statements
}

Example 1.18:
Other documents randomly have
different content
“Why didn’t you say so before?” I asked, roughly.
“You never asked me,” said he. “The chaplain has known me many
years.”
“Well,” I cried, rising and advancing upon Mr. Raymond, “you’ll
either drink this ale or get it in the face, for I’ll not be badgered by
every hairy heaven-yelper I run against. Drink!” and I held the mug
toward him.
His fierce eyes gleamed curiously, and he reached for the tankard.
Then he raised it to his lips, and the long moustache was buried half
a foot in the foam. When he let it down it was empty. The next
instant something crashed against my head, and I saw many stars.
Then came a blank. It must have been some minutes before I came
to, and, when I did, I found myself lying upon the floor with my Mr.
Henry and the barmaid wiping the blood from my face. The tall man
had disappeared, and I struggled to my feet, my head whirling.
Upon the floor lay pieces of the mug.
“Did that sky-pilot do it?” I asked, feebly.
Henry grinned.
“Ah, ah, pauvre garçon, pauvre, pauvre--what eet is, boy? Pauvre
boy. C’est poar boy, poar boy,” said the stout girl, wiping my clothes
gently and laying a hand on my shoulder.
The effect of a little sympathy was strange, especially from a
woman.
“Never mind,” I said, taking her hand from my shoulder and
holding it a moment. “Get some fresh ale. There is no damage done.
If that fellow was a man of peace, I should not like to come across
his breed as man of war. Sit down, you son of a fox,” I continued to
Henry, “and let’s have your yarn, and if I see you so much as grin,
this shop will be unlucky.” We drew up again to the table.
“I should think,” said Richards, “you have had your say long
enough now, and would listen to reason. Steady yourself and get
back into some ship before you get in jail. I don’t care any more for
the hooker you just left than you do, and wouldn’t go back in her if
there was any other vessel wanting hands.”
“I feel flattered at your attentions, my dear Peter,” said I. “It is
good of you to follow me to take care of one so young. My morals
are pretty bad, and I need a nurse.”
“That is certain,” said the sailor, with conviction that angered me
not a little.
Richards’s manner was a bit trying to me at all times when I
wanted to have a say, and this time I lost patience. Yet, when I
thought of it afterward, I saw a steady head would have kept me out
of much trouble. He was a perfectly balanced man. He would neither
lose his head with joy, nor sink with despair at some seeming
desperate trouble. He had learned this by experience, and his steady
eyes were not those of a dullard. He felt as much as any one, as I
soon learned when I gave him the sharp edge of my tongue. He was
not a large man, but rather small and wiry. His size, I often thought,
had governed his actions, for aboard ship a small man cannot talk
too loud. Since he had served with me, I had reason to believe his
body had little to do with his mind.
“Peter,” I said, acidly, “I’m looking for a ship. Will you go along in
her with me?”
“That I will,” he said, but I thought he was simply falling into my
trap to gain time.
“Then, my weasel,” said I, turning to Mr. Henry, “you have two
bully boys at your tow-line, for, sink me, I’ll hold my mate to his
word if I ship in nothing better than a West Indian sugar-boat. Sail
in, my bully. Let’s have the old tune I’ve heard so often.”
Henry drew up his chair and gloated over us. We were two good
enough men to tempt any sort of crimp, but, on account of my size,
he addressed himself to me as the leader. I have always had this
happen when there were others around, but I take no especial note
of it, for it was nothing that I was a well-put-up man. I had nothing
whatever to do with my birth.
“You see,” said he, “I don’t make any bones wot I’m up to. I’m
after men sech as you an’ me. My father were a Yankee sailor,
though my mother were sech as I have to break the commandment
wot arguefies for a long life every time I think of her.”
“You can honour her memory by keeping her name off your
tongue,” I growled.
“Perhaps so,” he assented; “maybe, but she were hung right here
in this town, and her property taken, so that’s why I’m lookin’ out fer
men wot’s men. I get ten shillings a head per sailormen, an’ I stands
in with the crowd. No shanghai business with me. It don’t pay. Why
should a man ruin his business just to shanghai one or two men who
will turn against him as soon as they come back, hey? A matter o’ a
pound or two an’ a good name fer fair dealin’ gone. Oh, no! I don’t
run fer bad ships. I only takes the clippers, an’ I give handsome.”
“What’s the hooker’s name?” I asked.
“That’s just what I’m coming to if you’ll only say the word to go in
her. They want a mate, and they’ll pay a big whack for a good man.”
“Name, you wolf,” I repeated, draining my mug. “Give the name,
or pay for this ale and clear.”
“I’ll take you to her--”
He was interrupted by the entrance of a small man who strode
quickly into the room and sat at once in an empty chair near the
door. As the newcomer entered, Henry half-rose and saluted,
receiving a slight nod of recognition in return.
“Who’s your friend?” I asked, gruffly.
“Sh-h! not so loud,” and he scowled at me. “That’s Captain
Howard.”
“Who the saints is Captain Howard? Can he drink ale?” I asked.
“I wouldn’t ask him if I were you. He’s not a man of peace,” and
he looked at me slantwise.
“I see,” I answered, and I looked the stranger over carefully. He
was quite small in stature and his face was pale. His hands were
soft, white, and effeminate-looking. Upon one finger a huge
diamond sparkled. Just then he turned his gaze to meet mine, and I
must admit his eyes gave me quite a turn. They were as glassy and
expressionless as those of a fish. His whole smooth face, in fact,
seemed to express nothing but vacancy. I had never seen a human
face so devoid of expression. There was hardly a line in it save about
the drooping corners of his mouth.
“He don’t look dangerous,” I said, with a chuckle. “However, I’m
not hunting trouble, and, if you think he’ll be offended at my
acquaintance, he can go without it.”
“He’s related to the great English house,--them--them ar’stocrats,
ye know. That’s the way he’s got the king’s pardon.”
“Pardon for what?” I asked.
He glanced sidewise at me with that ferret look upon his face.
“You’ve heard, sure? No? Well, then, that’s the skipper that held up
the Indian Prince.”
Then I remembered well enough. He was the little fellow with the
pirate crew that had held up the big East-Indianman in the China
Sea some years back. It was he who took the treasure and
squandered it in mad riot in the streets of Singapore, and defied the
authorities. Here, indeed, was the man feared by both whites and
savages of the Eastern seas, sitting in this little ale-house as
unconcerned as though nothing unusual had happened to excite
curiosity. I was so taken up looking at him and wondering at his foul
crimes that he had received and drunk off his liquor before I realized
what had happened. As he left, I seized my mug and drank it.
“Come along,” I said. “Show me your ship,” and Mr. Henry paid the
score and started for the door, while I followed. As I reached it, I
turned to see what Richards would do, but he was game.
“Here comes your nourse, sonny,” he said. “I was paid off
yesterday, and don’t mind a change if it’s for better,” and he looked
so serious that I burst out laughing.
CHAPTER III.
THE BARQUE

Henry led the way through the streets until we came to the
anchorage basin beyond the docks. He was talkative enough, but my
head ached from the blow I had received from the man of peace,
and I paid little attention to the fellow’s words.
We passed a large American ship that had been captured by the
English during the war and sold. She loomed up grandly from the
small craft lying near, her long, tapering masts still showing the
unmistakable Yankee rigging, and her yards having yet a vestige of
the white American cloth which has since been a pleasant feature of
all our craft. Her paint was worn off, however, and upon her decks a
mongrel crew chattered away like a pack of monkeys. I halted a
moment and looked at her in disgust.
“What ship is that?” I asked.
“The Independence of Boston. She were taken by the English line
ship St. Marys off Cape St. Roque. She were stove up some. See
that big piece spliced into her stern where she was shot away. Her
mainyard’s fished in two places. Took two whole broadsides to fetch
her to, they say. That trim-lookin’ craft beyond her is the one we’re
headin’ fer,--the one laying head on with the foreyards cockbilled.”
We went toward the vessel indicated, and I soon saw what indeed
appeared to be a fine craft. She was large, probably five hundred
tons, but she was barque rigged, with her mainmast stepped well
aft. Her foreyards were lifted to starboard and her main were braced
to all angles, giving her the appearance of having been suddenly
deserted by her crew after making port. Upon the spars the white
canvas lay bent and furled, the clews standing out a foot or two
clear of the bunt, and the gaskets hove in taut as brass bands. Her
black sides showed a good freeboard, but I thought little of this, as
nearly all vessels bound to the westward were going pretty light at
that time. She was coppered, and the top band was a good half-
fathom clear of the water. She was pierced for six guns on a side,
and had several more ports painted along the bulwarks on the main-
deck, as was the custom of the day. At a distance she might have
been taken for a vessel of twenty or more guns. Her build was
English, but her rig was Scandinavian, and I noticed her poop was
painted white everywhere except on deck, after the Yankee fashion.
Three heavy boats were slung amidships on booms. Forward of
these a galley was built or lashed upon the deck, and from its
window appeared the black head of an African. We went close to the
water’s edge and Henry hailed.
“Th-war-bull-yah! Ahoy!” he bellowed.
“What’s her name?” I asked.
“Ha-Yah-Wah, ahoy!” he bellowed again in answer, and the nigger
in the galley waved a white rag in reply.
“May the sharks eat me, you dock wrastler, but that’s a queer
name for a fine ship! How do you call her?” I asked.
“He’s comin’ now,” said Henry, with a grin. “Names is mostly just
sounds, an’ furrin sounds is just like others, only different. We’ll go
aboard her, and you can see the old man an’ settle with him. Don’t
be afraid o’ high pay. He’ll give it.”
In a few minutes a boat left the barque from the side opposite us,
where it had been out of sight. It rounded under her stern and came
toward us, with the nigger standing aft sculling with the peculiar
swing of the Bahama conch. He landed almost at our feet, and
Henry motioned me to jump aboard.
“Ole man aboard, hey?” asked Henry, stepping in after me.
“Yassir, disha boat just done taken him abo’d. He’s done expected
mos’ all han’s afo’ dis.”
“Well, take us over,” said Henry, and he settled himself heavily
upon a thwart.
In a short time we were alongside. We clambered up a long
hanging ladder amidships, and then over the rail to the main-deck.
As we did so a venerable, white-haired old fellow stepped out of
the cabin door and greeted us.
Henry took off his cap and bowed with uncommon civility.
“Captain Watkins, allow me to make known Mr.--Mr.--”
“Heywood,” I suggested.
“Mr. Heywood,” continued Henry. “He is the best mate in Havre,
an’ is just off the American ship Washington. I knowed you wanted a
good mate, so I brought you the best in town.”
The old fellow held out his hand gravely, and said how glad he
was to make my acquaintance.
“I am just looking for a good navigator, and if you’ll come at my
terms, I’ll reckon we’ll deal.”
I suggested that the terms be made known.
“Well, I reckon on thirty pound a month is all I allow just now. Will
you consider that?”
As this was five times as much as any mate I had ever heard of
received, I told him I would consider the matter closed.
“An’ your friend, here. I take it he is an American, too,--an’ a
sailorman from clew to earring.”
Richards looked at him steadily.
“You are a right smart of a guesser, Mr. Watkins,” said he. “I was
second in the Washington, but I’ve been in better ships.”
The insolence of old Peter calling the captain mister was almost
too much for me. Here was a chance of a lifetime. I turned upon
him.
“If you are going to act foolish with one drink of ale, just for a
chance to back down, you better get ashore,” I snapped.
“I’ve seen many men more sensible drunk than you are sober,
Heywood,” said he, looking calmly at me, “but I’ll not back down.”
“Will you accept the same terms?” asked the old man, kindly.
Richards looked at him in scorn. Then he spat on the white deck.
“I’ll go,” said he, and Captain Watkins turned to me.
“There is no grog served aboard, and no swearing on this ship, Mr.
Heywood,” said he. “I am an old man, as you see, and wish my crew
orderly and quiet. Do you wish to stay aboard at once?”
I said I would just as soon turn to at once. The rate of pay fairly
frightened me, and I was afraid if I went ashore he might get some
one else in my place. The appearance of the barque was much in
her favour. Her decks were as white as holystone could make them,
and her gear was all new and carefully selected. Such lines seldom
found place upon any ships save men-of-war, and her blocks, with
polished brass pins and sheaves, were marvels to me. I stood idly
pulling a topsail brace with one hand and looking up at the fine
rigging, while Henry talked of his tip for bringing me. Even the
sheer-poles were polished brass. The old fellow finally led us below,
and handed Henry a small gold piece, and then offered me a few
pounds in advance, requesting me to sign a receipt for the same.
This I did, and then Henry left, shaking me heartily by the hand as
he went over the side. I returned his grip, for I felt he had indeed
been my friend.
“You may take the port room there, Mr. Heywood, and put your
things shipshape as soon as Henry gets them off your vessel. If the
second or third mate comes aft to see me, don’t fail to call me,--er--
er, you know I’m quite without officers, sir, but will probably have
both them and a crew aboard soon. The papers have not been made
out yet, but I believe I have your receipt for your advance.
Witnessed by Henry, it will do, I suppose, but I am not afraid of you,
Mr. Heywood. You don’t look like a man to take advantage of a ship’s
generosity.” Then he went aft, and I went to the port room. It meant
that I was first mate, and I opened the door with a high heart.
There was nothing at all in the stateroom save an old clay pipe
and a twist of tobacco. The bunk was bare, and I sat upon the edge
of it speculating upon my good fortune. Finally I lit the pipe and
smoked. The smoke wreaths rolled upward, and, as I watched them,
I built many pleasant things in the future.
How long I dreamed I don’t know, but it was quite late in the
afternoon when I heard a hail from the shore that sounded like
Henry’s. I went on deck and met the nigger coming from the galley
to the boat. I noticed what a strapping buck the fellow was, and he
saw me watching him.
“Disha hooker’ll have er crew soon. Yassir, she will dat,” said he,
grinning and showing a row of teeth almost as pointed and white as
those of a shark. Then he climbed over the rail, and was soon
sculling to the shore, where I saw Henry and two men waiting.
They came aboard and were ushered into the cabin by the
venerable skipper, whom I had awakened.
“This is Mr. Martin,” said Henry, introducing the first one with the
air of a man presenting a lord. The fellow pulled off his hat and
squared his shoulders, and then looked somewhat disturbed by this
mark of respect. He was clean shaven, with a great broad head set
upon an enormous pair of shoulders. He was short but powerfully
built, and his bright eyes were restless. He was no drunken ship-rat,
but a strong, healthy sailor.
“Mr. Martin, it gives me pleasure to meet you, sir. As I understand
you wish to sign as second mate, I present you to Mr. Heywood, the
first officer,” and he nodded to me with a graceful sweep of the
hand. He had evidently forgotten Richards, but I did not feel inclined
to remind him at that moment.
The fellow looked at me and scowled, at the same time nodding.
This sort of thing was more than he had expected. Then he broke
forth in broad Scotch that he would sign or go ashore.
“Would twenty pound a month do you?” asked the skipper,
wistfully.
The fellow did not understand. The amount probably dazed him.
Captain Watkins repeated the offer.
“Weel an’ guid! weel an’ guid!” he cried, slapping his stout leg.
“Let’s have a squint o’ th’ goold.”
“I shall be glad to hand you a few pounds at once in advance,”
said the old skipper. “Please sign this receipt for four pounds,” and
so saying, he produced the money.
The fellow put it in his clothes and signed the paper at once.
His companion stepped up. He was a Swede and blond. His blue
eyes were bleary with liquor, and the old man looked at him and
shook his head sadly.
“No drinkin’ and no swearin’ aboard here, my friend--er--er--”
“Anderson,” said Henry.
“No drinking here, Mr. Anderson. If you’ll accept fifteen pounds a
month and three pounds in advance, just scratch off a receipt and
we’ll finish up and have dinner.”
This was done and the two men saw Henry over the side, giving
him, as I had done, a good tip for his kind interest in getting them
such fine berths. Then the big nigger cleared the table and brought
in a very substantial meal, at which the captain and we mates fell to.
I was not a little astonished at the appearance of Richards. He
was all cleaned up and wore a scarf tied under his newly shaved
chin. He was always neat in appearance, but here he was, without
anything apparently to tog out with, all rigged as fine as though he
were going ashore. His smooth face, sunburned and lined as it was
from exposure, seemed to tell of much hardship in the past. He was
a solemn-looking fellow at best, and to see him togged out in this
shape, with his hands washed and old clothes brushed, was strange.
He took his place at the table without a word.
“You see,” said Captain Watkins, looking at me with his sharp
eyes, “I believe in the equality of all men.”
I nodded, for it was not often the mates and sailors of a ship had
a chance to eat in the forward cabin of a vessel, especially together.
The Scotchman, Martin, eyed the old fellow narrowly. We could not
all be mates.
“One man’s as good as another, and sometimes even better,” said
Richards, softly.
“That’s it. Even a black man is as good as a white one. Some
people don’t think so, but I know it’s so,” said the skipper.
“I’ve seen some I thought better,” said Richards, helping himself to
a piece of boiled meat, “but it don’t keep people from jerking them
up for slaves when they get a chance.”
“I have known slavers,” said the old man, gently, “but they are a
rough set and capable of any crime. On our last voyage one of those
fellows wanted to visit me during a calm, but I was afraid of him and
warned him away. A desperate-looking set they were.”
“Must have frightened you badly,” sneered Richards.
The old skipper looked at the sailor. There was something like
sadness in his voice as he answered.
“I’m of a somewhat timid nature, but cannot help it. I cannot
stand seeing poor coloured folk made to suffer. You will know me
better after you have sailed with me for a voyage.”
I thought I saw just the glimmer of a smile around the corners of
his mouth as he said this, and looked for some reply from my
talkative mate. Richards made no further remark, and the
conversation turned to more sailor-like topics.
We talked rather late, as the skipper was most fatherly in his
manner, and, when the fellow Martin suggested he would go ashore
and get his dunnage, it was found that Henry had taken the boat
without the nigger, and had not sent it back aboard.
“It is of no great consequence, I hope,” said Watkins. “You two,
Mr. Heywood and Richards, may turn in the port room; you, Mr.
Martin and Mr. Anderson, to starboard, and perhaps in the morning I
can let you have the day ashore.”
Then we separated. Richards and I tossed a coin to see who
would get the bunk, and I won. I arranged my coat for a pillow and
soon fell asleep, leaving my roommate to shift for himself on the
deck.
Once or twice during the night I thought I heard stealthy footsteps
overhead, and once it seemed to me that the barque was heeling
over a bit. Finally I was awakened by a loud banging at my door,
and, springing up, found it was broad day. Then it suddenly dawned
upon me that the barque was under way.
Opening the door, I found a strange fellow scowling at me. He was
dressed as a common sailor and was a bit drunk.
It is just as well to start discipline right aboard a ship, thought I,
so I hitched my trousers’ belt the tighter before sailing in to show
how an American mate whangs the deviltry and liquor out of a
foreign skin when aroused from pleasant dreams. I noticed the
absence of Richards, but thought he had already turned out for duty.
Then I accosted the fellow and asked softly what he wanted.
“What cher doin’ in my room, yer bloomin’ swine?” he howled. “Git
out an’--”
I had stopped him with a right swing on the jaw, and the next
instant we were loping about that cabin in fine style. In a moment
there was a rush of feet, and something crashed on my head. Then
followed stars and darkness.
CHAPTER IV.
SHANGHAIED

When I came again into this world, I found myself lying in a dark,
dirty hole of a forecastle. There was not a man there, but, as I
looked over the empty berths, I saw plenty of clothes and bedding,
which gave evidence of a full crew.
Getting to my feet, I found my head sorely cut and bruised, and
wondered what had happened. A throbbing pain across the eyes did
little to aid my thoughts, and, while I stood holding to the ladder
down which I had been flung, the scuttle above me was thrust back
and the fellow Martin started down.
“Aha!” he said when he saw me, “’twas a guid wan ye got ain yer
haid. A clout will do ye na harm, ye thievin’ trixter, ye deceivin’
rascal. Now I’ll give you one for ald lang syne, an’ teach ye better to
deceive a honest mon ag’in.”
While talking, he turned back the sleeves of his jumper and made
ready to carry out his threat. He saw I made no movement,
however, and hesitated.
“Defend yairself, mon, defend yairself. Do not let me whollop yer
like a babe,” and he advanced toward me with his hands before him
in some very fair style.
“See here,” I said, “what the mischief has happened? What are
you driving at? I’ve played no trick, but it looks like some one has
played a trick on me.”
“Ah, na backslidin’, ye corward, na backslidin’! Yer can’t fool a
canny sailormaun that way. Put yer hands before yer ugly face, or I’ll
whollop ye like er babe.”
“I’m not afraid of your wholloping, Scotty. Let me get a turn about
my head a bit, and pull this ragged shirt off. Wonderful clean
fo’castle this. No drunks, no filthy dunnage overhauled, no--what
infernal ship is this, anyway?”
He saw I was not joking. Indeed, my appearance, as his eyes
grew accustomed to the gloom, put joking aside, and my last remark
about the vessel was true.
He dropped his hands and stared at me.
“Ware ye sure rung in like the rest? Waren’t ye in the game?”
Then he burst into a hoarse laugh and held out his hand. At that
minute the tramp of feet sounded overhead, and a half-score of men
came clattering down the companion-ladder.
It was a mixed crew,--Norwegians, Swedes, dagoes, and
Dutchmen,--but all with the unmistakable swing of the deep-water
sailor. They stared at me, and then started a gabble of language that
in my disturbed condition I failed to understand. They crowded
around me and asked questions, and I noticed Anderson eyeing me
suspiciously. Then Martin, with a sweep of his hand, cut them off,
and began telling how I came aboard. When he was through with
his flowery description of Henry, I noticed several men shake their
clenched hands aft.
“Well,” said I, “I’m the mate, and I guess I’ll go aft and find out
who rapped me over the head. Some fellows in the other watch, I
suppose.”
They burst into derisive laughter.
“We’re all mates and captains here,” sung out a big Norwegian
addressed as Bill. “You better turn in while you may, friend
Heywood. You’re in Henry’s watch, an’ the captain ain’t turned out
yet.”
“Who’s the old man?” I asked, bewildered, and thinking I must still
be daffy from the crack on the head.
“Ain’t seen him yet,” said several at once.
“Well, what infernal hooker am I in, anyway?” I asked Martin.
“They call her The Gentle Hand, but there ain’t na name painted
on her. Some says she’s the Fly-by-Night, Howard’s old pirate
barque, but that canna weel be. She’s light. Not a hundred ton
below decks, an’ that’s mostly stores.”
“The Fly-by-Night was a cruising brig before the first war with
England,” I said. “It can’t possibly be that old hooker. Besides, she
was used against the French by your General Braddock.”
“Well, when you find out just what we’ve gotten into, coom an’ tell
us,” said Martin.
It had been slowly dawning upon me that I had been the victim of
a trick, and I felt in my pocket for the advance I had received the
day before. The barque was under way, that was certain, but no one
seemed to know where she was bound, and, as I fumbled through
my clothes, Martin laughed.
“’Twas guid money, Heywood, but ’tis gone. I missed mine this
morning. Maybe Anderson can tell where it is,” and he grinned.
The money was gone. That was certain. Yet it was no dream. I
had received it fair enough. Feeling anger and hatred for the trick
upon me, I bound up my head and went up the ladder to the deck
to have a look around. Several men called out to me to have a care
of the mate, but most of them were busy arranging their belongings,
quarrelling and fighting among themselves over the possession of
what clothes happened to be common to the crowd. I saw Martin
steal a pair of tarpaulin trousers from a fellow who was wrestling
with the sailor Bill for the possession of a bag of straw bedding.
Then I stepped on deck.
The cool air did me good. I went to the rail and looked over. The
barque was going steadily to the southward with every rag set. She
was heeling but gently, and there was little wind or sea. She was
braced a bit to starboard, her port tack aboard, and by her trimming
I saw she was under English officers. Every yard just in line with its
fellow, from the big main to the little royal that crossed a good
hundred and seventy feet above the sea. Far away to the eastward
showed the even outline of the French coast, and between us many
sails strung along the band of blue, their hulls either just below or
rising above the horizon’s line. The day was fine and the easterly
breeze gentle, and the barque was swinging easily along.
I looked aft and saw men of the mate’s watch at work setting up
the backstays in the main-rigging, and some on the mizzen topsail-
yard, apparently under the direction of Richards, serving a worn
foot-rope. The canvas covers were off the guns, and a dozen bright
twelve-pounders of polished brass shone in the sunlight. The white
deck beneath and the varnished spars above made a pretty picture,
and I grew warm to think that I was not indeed the mate of such a
craft. They had played a fine trick on me to get me aboard sober
and without compulsion, signing a receipt for an advance equal to a
couple of months’ ordinary wages. There were plenty of sailors
about the pier-heads, for the war had turned many adrift without
means of getting a ship, and there seemed to be no reason why
these fellows should try their land-shark game in getting a crew.
As I looked aft it dawned upon me that these men were much
better than the ordinary run of common sailors. There was
something in the fellow’s walk I now saw crossing the deck that
spoke of the war-ship. Even the watch I had just seen below were
remarkably rough and tough specimens of a rugged humanity.
While I stood there taking in the scene, I saw a man come from
aft and walk to the break of the poop. He looked over the barque
carefully, and as his gaze came down the fore-rigging it stopped
upon me.
He was dressed something after the manner of a preacher, with
black cloth coat and stock, and his hair was cut short. As I took his
figure in, there was little difficulty in recognizing Richard Raymond,
the man of peace. He beckoned me to come aft, and, as I did so, he
removed the huge drooping moustache he had been wearing and
tossed it over the side.
“I reckon you know me now, Heywood,” said he, “though it’s been
over six years since we parted. I wanted you on this voyage, and
took some pains to get ye. That was the old man who welted ye
over the head. I’m sorry for it.”
It was Hawkson, sure enough. I recognized him easily now in spite
of his gray hair and older look. How I failed to recognize him at first
even in his disguise puzzled me. We had made the cruise in the
Petrel together, and had served on the man-of-war.
“Well, you’ve got me fast enough, though you played a mean trick
getting me. Now what’s the game?” said I.
The old privateersman smiled, and his jaws worked as though
muttering to himself. His face creased into ugly lines about his large
mouth, and he showed his teeth.
“I’m first officer here. That fellow Gull you fouled this morning is
second. Remember this first and the rest’ll come easy. Henry is third
mate, and I hear them say that you’re to be made gunner. How’s
that?”
“Who’s them?” I asked, somewhat nettled.
“Them’s us, sonny. The old man, the two gentlemen aft, myself,
and the rest.”
“Where are we bound for, and what’s the hooker’s name? It’s all
well enough to be cribbed aboard a ship, but I’m going to find out
what’s the game.”
“We’re bound for the South Pacific; that’s all clear as mud, an’
we’ve got a picked crew because the business in hand needs honest
men.”
“I bow to myself,” I answered. “It’s well to know.”
“What more do you want, hey? Go forrads an’ turn in, an’ I’ll
square ye with the fellow Gull. Don’t let them see me talkin’ too
much with ye, sonny, or I’ll have to forget the past for the needs o’
the present. You’re aboard a fine ship.”
“Well,” I answered, “that’s all good enough, but I would like to
know her name and who’s her skipper,--and what’s more, I’m going
to find out right away.”
Hawkson’s eyes glinted with that light I knew so well meant
danger, and his ugly mouth worked nervously.
“Perhaps you’d care to go aft and interview the captain about it,”
said he, with his drawl. “He’s a gentleman every inch, and will be a
revelation to ye after them packets you’ve sailed in. Suppose you lay
aft and make out your own case. You were always an obstinate
youngster, but I reckon since you’ve been mate your head’s swelled
worse’n ever.”
I knew Hawkson to be one of the most dangerous men afloat
when aroused, but about this time I was not exactly a lambkin
myself. A man does not become mate of a western ocean packet
with anything lamblike in his make-up, unless it is by accident for
one voyage. I was not quarrelsome, but resented with righteous
indignation the manner in which I had been kidnapped in broad
daylight without even being under the influence of liquor. The
simplicity of the whole affair maddened me, and not even the
fellowship of Martin and Anderson or others in the list of victims
detracted one jot from the implied lack of ordinary precautions and
common sense. I started up the weather side of the poop to go aft,
and I noticed several fellows to leeward looking at me.
“Go to lor’ard,” growled Hawkson, fiercely.
But I paid no attention, and was half-way up the steps when a
man came up the after companion and walked toward me. As he
reached the deck and turned before I had gotten up, I stopped
short, looking at him. It was Captain Howard, the pirate.
CHAPTER V.
IN THE FO’C’SLE

I will admit my zeal abated a trifle when I met the captain’s gaze,
but I was not much afraid of any man, so up the ladder I went and
toward him.
He saw me approaching and stopped. Then he demanded in a
high voice from Hawkson what I wanted and why I was allowed up
the weather side of the quarter-deck.
“He’s a bit daffy, sir,” said Hawkson, touching his cap. “That crack
on the pate you gave him has turned his burgoo case. He’ll be all
right soon, sir.”
“Daffy or not,” said I, “I want to know what ship I’m in and where
she’s bound,--and I’m going to find out.”
The ugly face of Captain Howard was inscrutable. His glassy eyes
like those of some reptile were fixed upon me. His thin, hooked nose
appeared like the beak of an albatross. He took off his hat and
bowed to me politely, saying:
“It will give me great pleasure to listen to you, sir.” I noticed his
poll was as smooth and hairless as the sole of my foot, only a red
seam that stretched from the crown to his left ear wrinkled its
bronzed roundness.
“Well,” I said, more mildly, “I would like to find out what ship I’m
in and where she’s going.”
“Were you drunk, sir, when you came aboard her?” he asked,
calmly.
“I was not,” I answered, warmly.
“Were you blind?”
“No, sir.”
“Well, then, you have permission to look about you, and, if you’re
the sailor you claim to be, you will perceive this is a barque. She is
called the Gentle Hand. She is bound for the South Atlantic.”
“But I shipped as mate of her,” I stammered.
“That is manifestly impossible. Mr. Hawkson has been mate of her
for some time. That was probably a little joke of Watkins, the
steward.” Here he threw up his head and burst into a rattling laugh,
his mouth slightly open, but his face otherwise unmoved.
“He, he, he!” he rattled, “you’ll be a mate fast enough,--a gunner’s
mate. And, if that don’t suit you, Mr. Hawkson will introduce you to
the gunner’s daughter. Go forward now and remember that if you
come on the weather side of the quarter-deck while I’m here, I’ll
write my name on you with a hot iron. Do you see? Ho, ho, ho! That
Watkins is a tricky knave and you have my permission to manhandle
him. There he is now. Breakfast--”
As he spoke, the venerable old scoundrel emerged from the door
of the forward cabin, and, standing upon the poop step, announced
that the morning meal was ready. There was little left for me but to
get forward. The “gunner’s daughter” on that ship I knew was the
sinister name applied to the breech of one of the guns, and an
introduction consisted of being held over it with a naked back, while
a sailor cut the victim to ribbons with a cat-o’-nine-tails.
As the old rascal Watkins stood there announcing breakfast, he
recognized me and grinned.
“It isn’t well to laugh early in the morning,” I said, as I went past
him. The captain went below, and I stopped on the last step of the
poop-ladder. “For sometimes it’s rude.” Here I caught him a cuff with
the flat of my hand that sounded all over the deck, knocking him a
couple of fathoms toward the main-hatch. A man to leeward laughed
outright, and even Hawkson chuckled.
The old fellow recovered himself, and his grin was conspicuously
absent as he came toward me in a menacing manner.
“Now you trot along, Noah,” said I. “I’ll give you one like that
every little while until I find that advance money back in my pocket.”
He stopped in front of me, and his mouth worked nervously. His
eyes seemed to disappear under his shaggy brows, and his beard
fairly bristled with rage.
I was a stout man among stout men, and he saw there was little
use speaking out loud. Then he turned and went into the cabin,
where Captain Howard was bawling for him to bring his coffee.
“Better have let the old man alone, Heywood,” said Hawkson.
“There’s a lot of trouble bottled up in his old carcass.”
“Well, I’m uncorking a few of my own,” I said, “and if that second
mate turns out while I have my hands warm, there’ll be some more.”
Hawkson chuckled.
“You’re taking things rather hard, ain’t ye? You’ll be mighty glad
they took ye aboard the old pirate before you’re through.”
“Well,” I said, “you’ve not answered my question, and I’m going to
find out a few things in my own way. Piracy is nonsense these days,
though if there were such things, you’d be in them all right. How did
that skipper get command of this vessel, anyway, and where is she
headed for?”
“I told you we were bound for the South Atlantic. Just where,
you’ll find out by the time we get there. We’re to stop at Nassau to
take the owners aboard and then go ahead. That’s all there is to it.
Sailing to the Bahamas and then around the Cape of Good Hope
over to where the owners want to go. That’s plain as mud, ain’t it?”
“How about the pay? Do you suppose I’ll go for nothing?”
“The pay is good, no fear. You won’t lose anything. Why, most of
these fellows here have shipped without knowing any more’n you
do, so what’s the use making trouble for yourself? It’s a regular
trading voyage. Just plain trading in the Atlantic, an’ if we get the
best of some trades, why--so much the better for the owners and all
hands. The owners are all right, sonny, an’ they’ll be here to settle.”
“Well, if you had only told me this,” I answered, “I would probably
have shipped anyhow, though I don’t care about going forrard
again.”
“That’s what I was afraid of, an’ the officers’ berths were full.
Three or four o’ the A. B.’s forrards has been mates before. You’ll be
all right as gunner if you leave this after-guard alone. It’s goin’ to
take all your care now to clear Watkins. He’ll kill you the first chance
he gets.”
“Bah!” I said, turning to go.
Hawkson left me and went aft. I hesitated a few moments, looking
around to see if any one on deck had heard our talk, but there was
no one near enough, and those who saw us might have thought the
mate was giving me a reprimand for whanging the old steward.
Hawkson would be friendly in a rough way, and I did not care for all
hands to know it. As I was in Mr. Gull’s watch, I had four hours
below before confronting that gentleman, and I might as well take
advantage of them, as my head was very painful. Taking one more
look over the vessel and beyond where sunlight danced upon the
wrinkled blue surface of the ocean, I went to the forecastle hatch
and forthwith below. Here I took possession of a bunk which the
thoughtful owners had cleaned and painted, and, announcing my
claim to the watch who had finished a late breakfast, sat upon its
edge and munched a piece of hard bread.
“I see ye whack the old duffer Watkins,” said the fellow Bill.
“What’d yer hit him for?”
I told him, and looked at Martin to see if he agreed to my
accusations against the old rascal’s honesty. He smoked in silence.
“D’ye know who Watkins is?” asked a big Finn with a long black
beard, “because if you don’t, you’re apt to find out too late.”
“Do you know me?” I asked.
The fellow looked surlily at me.
“Because if you fellows down here don’t, some of you will find out
all of a sudden.”
I had noticed that they had left the mess things lying about, as if
awaiting something, and then I had a grave suspicion that the
something was myself, whom they would delegate to clean up after
them. It was just as well to take the matter in hand at the
beginning, and if there was to be a fracas to see who was to be the
boss of that crowd, the earlier the better.
The big Finn gazed at me, but said nothing, and Bill seemed to
size me up closely.
“Who and what is that old swab, Watkins?” I asked, suddenly
turning upon Bill.
“They say he was mate with Howard when he was a boy. Served
thirty years for a few things they did in the China Seas. Killed more’n
forty men.”
“Well,” I answered, “if some one had taken him in hand before
he’d killed the last thirty-nine, he would have a better chance than
he has now for keeping out of the devil’s company. Now you get
hold of those mess things, William, and make the Czar’s cousin here
lend a hand. If you don’t, I’ll make you wish Watkins was here to
run this mess when the watch is called.”
Here I lounged back in my pew, finishing off with a chunk of salt
beef and a cup of cold water. Afterward I lit a pipe and smoked
complacently, while keeping a lookout to see what the crowd would
do.
Bill was a fine specimen of the Norwegian sailor, and he surveyed
the mess things contemptuously for a few minutes. Then he seized
upon a stocky little Dane, and bade him carry the things away. The
men, having finished, were talking and smoking, sitting in their pews
or upon the sea-chests the more lucky happened to bring aboard.
They saw Bill’s move, and a murmur of disapproval ran among them.
Several pointed at me, but I smoked in silence, feeling much better
for having eaten something, and recovered my usual strength and
spirits. In a few minutes we might be called on deck, perhaps, to
trim sail, but if not, the after-breakfast smoke would be followed by
an arranging of the forecastle. The little Dane entered a loud protest
against his new duties, but Bill silenced him quickly with an oath.
“You do as I tell yer. I’ll settle with the Yank later,” said he.
“There’s no time like the present,” said I, putting my pipe away
and slowly rising out of my pew. “I’m the high cock of this roost, and
when I give an order below here there needn’t be any settlement
called for. Peel off! Get ready, for I’m coming for you, William.”
The loungers looked up, and Martin chuckled.
“Coom, coom, a fair fight, an’ may the best mon win,” he cried.
“Gie us room, laddies, gie us room. I’ll back the Yank, mon, and,
Anderson, ye knave, ye’ll back yer Scandinavian.”
Bill was not a coward, but he had the blood of a peaceful race in
his veins. He was very strong and able, and he cursed me heartily,
while I calmly pulled off my upper garment. His fierce threats only
made me more determined to put him through, for the more he
swore the angrier he became, telling plainly that the matter was not
so greatly to his taste.
As gunner or petty officer of any rank aboard ship, it was
absolutely necessary to make a clear start, in order to avoid
disagreements later. The weaker must be made to act as cook for
the mess, and there was no help for it. It was the rule that had to be
established in the same old way.
Martin drew a line across the deck with a piece of charred wood. I
stepped up to it and placed the toe of my left foot upon it and was
ready. Bill quickly swaggered up, and I landed like lightning upon his
jaw. He staggered back into the arms of Anderson. Then he spit out
a mouthful of blood, and came at me with an oath and a rush.
CHAPTER VI.
I BECOME “COCK OF THE WALK”

There was nothing brutal or rough in this encounter, and, if it


savours of the commonplace sailor’s brawl, I can only say that such
are the customs on deep-water ships, and they must continue
through all time. Life at sea is not always gentle. There is no use
trying to make it so. It is nearly always a fight against the elements,
and the roughness prevents the customs from becoming effete as
those of the drawing-room, where an easy tongue and sarcastic wit
does the hurting. This is said to be refined and not brutal, but for my
part I have seen men more brutally and cruelly hurt by words than
by fists. A person with a weak stomach will stand an uncommon lot
of verbal brutality, but when it takes a physical form, they shrink
from it and cry out that it is degrading. It is less degrading than a
vile tongue.
When Bill landed upon me, there was something of a mix-up, and
some short-arm work that might have proved interesting to lovers of
sport. We were in pretty good training, and the thuds of our blows
sounded healthily through the little forecastle. The men lounging in
their pews and gazing complacently at us, their bodies and legs well
out of the way, made a very appreciative audience and left the deck
perfectly clear. Their remarks were not always well advised, for they
clamoured loudly for Bill to put the finishing touches to me, while I
jolted him repeatedly upon the side of his bullet-head.
Finally Martin and Anderson separated us for a breathing spell,
and I had a chance to look about the room with the one eye left me
for duty. Then I noticed the companionway blocked by the forms of
two men who were somewhat remarkable in appearance. They were
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about books 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!

ebookball.com

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy