Get Data Structures & Algorithms using Kotlin, Second Edition Hemant Jain free all chapters
Get Data Structures & Algorithms using Kotlin, Second Edition Hemant Jain free all chapters
com
https://ebookmeta.com/product/data-structures-algorithms-
using-kotlin-second-edition-hemant-jain/
OR CLICK HERE
DOWLOAD NOW
https://ebookmeta.com/product/problem-solving-in-data-structures-
algorithms-using-c-2nd-edition-hemant-jain/
ebookmeta.com
https://ebookmeta.com/product/a-common-sense-guide-to-data-structures-
and-algorithms-second-edition-jay-wengrow/
ebookmeta.com
https://ebookmeta.com/product/data-structures-algorithms-in-python-
john-canning/
ebookmeta.com
https://ebookmeta.com/product/apostles-of-transformation-anthology-of-
muslim-women-trailblazers-in-india-akhtarul-wasey-juhi-gupta-eds/
ebookmeta.com
Find Your Way Home (Small Town Dreams #1) 1st Edition
Jackie Ashenden
https://ebookmeta.com/product/find-your-way-home-small-town-
dreams-1-1st-edition-jackie-ashenden/
ebookmeta.com
https://ebookmeta.com/product/mrexcel-2022-boosting-excel-6th-edition-
bill-jelen-2/
ebookmeta.com
https://ebookmeta.com/product/india-africa-partnerships-for-food-
security-and-capacity-building-south-south-cooperation-1st-edition-
renu-modi/
ebookmeta.com
https://ebookmeta.com/product/epicurus-and-the-singularity-of-
death-1st-edition-david-b-suits/
ebookmeta.com
Digitalization and Analytics for Smart Plant Performance
Theory and Applications 1st Edition Frank (Xin X.) Zhu
https://ebookmeta.com/product/digitalization-and-analytics-for-smart-
plant-performance-theory-and-applications-1st-edition-frank-xin-x-zhu/
ebookmeta.com
Data Structures &
Algorithms using
Kotlin
Second Edition
By Hemant Jain
https://t.me/KotlinSenior
Data Structures & Algorithms using Kotlin
Hemant Jain
Hemant Jain asserts the moral right to be identified as the author of this work.
The author is very grateful to GOD ALMIGHTY for his grace and blessing.
I would like to express profound gratitude to my family and friends for their invaluable
encouragement, supervision and useful suggestions throughout this book writing work.
Their support and continuous guidance enable me to complete my work successfully.
Hemant Jain
Table of Contents
CHAPTER 0: ABOUT THIS BOOK...............................................................................................................................1
CHAPTER 1: ALGORITHMS ANALYSIS.......................................................................................................................2
CHAPTER 2: APPROACH TO SOLVE PROBLEMS......................................................................................................24
CHAPTER 3: ABSTRACT DATA TYPE........................................................................................................................29
CHAPTER 4: SORTING............................................................................................................................................43
CHAPTER 5: SEARCHING........................................................................................................................................82
CHAPTER 6: LINKED LIST......................................................................................................................................153
CHAPTER 7: STACK...............................................................................................................................................206
CHAPTER 8: QUEUE.............................................................................................................................................243
CHAPTER 9: TREE.................................................................................................................................................267
CHAPTER 10: PRIORITY QUEUE / HEAPS..............................................................................................................346
CHAPTER 11: HASH TABLE...................................................................................................................................381
CHAPTER 12: GRAPHS..........................................................................................................................................396
CHAPTER 13: STRING ALGORITHMS....................................................................................................................447
CHAPTER 14: ALGORITHM DESIGN TECHNIQUES................................................................................................467
CHAPTER 15: BRUTE FORCE ALGORITHM............................................................................................................470
CHAPTER 16: GREEDY ALGORITHM.....................................................................................................................475
CHAPTER 17: DIVIDE AND CONQUER..................................................................................................................492
CHAPTER 18: DYNAMIC PROGRAMMING............................................................................................................503
CHAPTER 19: BACKTRACKING..............................................................................................................................541
CHAPTER 20: COMPLEXITY THEORY.....................................................................................................................550
APPENDIX............................................................................................................................................................559
Table of Contents
CHAPTER 0: ABOUT THIS BOOK...............................................................................................................................1
WHAT THIS BOOK IS ABOUT........................................................................................................................................1
PREREQUISITES.........................................................................................................................................................1
WHO SHOULD TAKE THIS COURSE ?..............................................................................................................................1
CODE DOWNLOADS...................................................................................................................................................1
END....................................................................................................................................................................... 1
CHAPTER 1: ALGORITHMS ANALYSIS.......................................................................................................................2
INTRODUCTION........................................................................................................................................................2
ASYMPTOTIC ANALYSIS OR ASYMPTOTIC NOTATIONS.......................................................................................................2
BIG-O NOTATION.....................................................................................................................................................2
OMEGA-Ω NOTATION...............................................................................................................................................3
THETA-Θ NOTATION.................................................................................................................................................4
COMPLEXITY ANALYSIS OF ALGORITHMS........................................................................................................................4
GROWTH OF FUNCTIONS............................................................................................................................................5
DERIVING AN ALGORITHM'S RUNTIME FUNCTION...........................................................................................................7
TIME COMPLEXITY EXAMPLES.....................................................................................................................................7
RECURSIVE FUNCTION.............................................................................................................................................13
COMPLEXITIES FROM RECURRENCE RELATION..............................................................................................................18
MASTER THEOREM.................................................................................................................................................21
EXERCISE...............................................................................................................................................................23
CHAPTER 2: APPROACH TO SOLVE PROBLEMS......................................................................................................24
INTRODUCTION.......................................................................................................................................................24
CONSTRAINTS........................................................................................................................................................24
IDEA GENERATION..................................................................................................................................................25
COMPLEXITIES........................................................................................................................................................26
CODING................................................................................................................................................................27
TESTING................................................................................................................................................................27
EXAMPLE..............................................................................................................................................................28
SUMMARY.............................................................................................................................................................28
CHAPTER 3: ABSTRACT DATA TYPE........................................................................................................................29
ABSTRACT DATA TYPE (ADT)...................................................................................................................................29
DATA-STRUCTURE...................................................................................................................................................29
KOTLIN COLLECTION FRAMEWORK.............................................................................................................................30
ARRAY..................................................................................................................................................................30
LINKED LIST...........................................................................................................................................................31
STACK..................................................................................................................................................................33
QUEUE.................................................................................................................................................................34
TREE.................................................................................................................................................................... 35
BINARY SEARCH TREE (BST).....................................................................................................................................35
HEAP / PRIORITY QUEUE.........................................................................................................................................37
HASH TABLE..........................................................................................................................................................39
ENDNOTE..............................................................................................................................................................42
CHAPTER 4: SORTING............................................................................................................................................43
INTRODUCTION.......................................................................................................................................................43
TYPES OF SORTING..................................................................................................................................................43
COMPARISON FUNCTION..........................................................................................................................................43
BUBBLE SORT........................................................................................................................................................44
INSERTION SORT.....................................................................................................................................................46
SELECTION SORT.....................................................................................................................................................47
MERGE SORT.........................................................................................................................................................49
PROS AND CONS OF MERGE-SORT ALGORITHM............................................................................................................51
EXTERNAL SORT (EXTERNAL MERGE-SORT).................................................................................................................51
QUICK SORT..........................................................................................................................................................52
QUICK SELECT........................................................................................................................................................54
COUNTING SORT....................................................................................................................................................56
RADIX SORT...........................................................................................................................................................57
HEAP SORT...........................................................................................................................................................59
TREE SORTING.......................................................................................................................................................59
SHELL SORT...........................................................................................................................................................59
BUCKET SORT........................................................................................................................................................61
GENERALISED BUCKET SORT.....................................................................................................................................62
STABLE SORTING....................................................................................................................................................63
COMPARISONS OF THE VARIOUS SORTING ALGORITHMS..................................................................................................63
SELECTION OF BEST SORTING ALGORITHM...................................................................................................................64
PROBLEMS BASED ON SORTING..................................................................................................................................65
EXERCISE...............................................................................................................................................................80
CHAPTER 5: SEARCHING........................................................................................................................................82
INTRODUCTION.......................................................................................................................................................82
WHY SEARCHING?..................................................................................................................................................82
DIFFERENT SEARCHING ALGORITHMS..........................................................................................................................82
LINEAR SEARCH OR SEQUENTIAL SEARCH – UNSORTED INPUT.........................................................................................82
LINEAR SEARCH – SORTED........................................................................................................................................83
BINARY SEARCH......................................................................................................................................................84
BINARY SEARCH IMPLEMENTATION USING RECURSION....................................................................................................85
FIBONACCI SEARCH.................................................................................................................................................86
HOW IS SORTING USEFUL IN SELECTION ALGORITHMS?..................................................................................................87
PROBLEMS IN SEARCHING........................................................................................................................................88
EXERCISE.............................................................................................................................................................151
CHAPTER 6: LINKED LIST......................................................................................................................................153
INTRODUCTION.....................................................................................................................................................153
LINKED LIST.........................................................................................................................................................153
TYPES OF LINKED LIST............................................................................................................................................153
SINGLY LINKED LIST...............................................................................................................................................154
DOUBLY LINKED LIST.............................................................................................................................................178
CIRCULAR LINKED LIST...........................................................................................................................................189
DOUBLY CIRCULAR LIST..........................................................................................................................................197
SKIP LIST.............................................................................................................................................................201
USES OF LINKED LIST.............................................................................................................................................203
EXERCISE.............................................................................................................................................................204
CHAPTER 7: STACK...............................................................................................................................................206
INTRODUCTION.....................................................................................................................................................206
THE STACK ABSTRACT DATA TYPE............................................................................................................................206
STACK USING ARRAY..............................................................................................................................................207
STACK USING ARRAY WITH MEMORY MANAGEMENT....................................................................................................209
STACK USING LINKED LIST.......................................................................................................................................210
SYSTEM STACK AND FUNCTION CALLS.......................................................................................................................213
PROBLEMS IN STACK.............................................................................................................................................214
USES OF STACK....................................................................................................................................................241
EXERCISE.............................................................................................................................................................241
CHAPTER 8: QUEUE.............................................................................................................................................243
INTRODUCTION.....................................................................................................................................................243
THE QUEUE ABSTRACT DATA TYPE..........................................................................................................................243
QUEUE USING ARRAY............................................................................................................................................244
QUEUE USING CIRCULAR LINKED LIST.......................................................................................................................245
PROBLEMS IN QUEUE............................................................................................................................................248
USES OF QUEUE...................................................................................................................................................265
EXERCISE.............................................................................................................................................................265
CHAPTER 9: TREE.................................................................................................................................................267
INTRODUCTION.....................................................................................................................................................267
TERMINOLOGY IN TREE..........................................................................................................................................267
BINARY TREE.......................................................................................................................................................269
TYPES OF BINARY TREES.........................................................................................................................................270
PROBLEMS IN BINARY TREE....................................................................................................................................272
BINARY SEARCH TREE (BST)...................................................................................................................................292
PROBLEMS IN BINARY SEARCH TREE (BST)................................................................................................................292
SEGMENT TREE....................................................................................................................................................306
BINARY INDEX TREE / FENWICK TREE.......................................................................................................................310
AVL TREE...........................................................................................................................................................313
RED-BLACK TREE..................................................................................................................................................319
SPLAY TREE.........................................................................................................................................................331
B TREE...............................................................................................................................................................336
B+ TREE.............................................................................................................................................................341
THREADED BINARY TREE........................................................................................................................................342
USES OF TREES.....................................................................................................................................................343
EXERCISE.............................................................................................................................................................343
CHAPTER 10: PRIORITY QUEUE / HEAPS..............................................................................................................346
INTRODUCTION.....................................................................................................................................................346
TYPES OF HEAP....................................................................................................................................................347
HEAP ADT OPERATIONS........................................................................................................................................348
OPERATION ON HEAP............................................................................................................................................348
HEAP SORT.........................................................................................................................................................358
PROBLEMS IN HEAP..............................................................................................................................................363
BINOMIAL HEAP...................................................................................................................................................369
FIBONACCI HEAP..................................................................................................................................................374
USES OF HEAP.....................................................................................................................................................378
EXERCISE.............................................................................................................................................................379
CHAPTER 11: HASH TABLE...................................................................................................................................381
INTRODUCTION.....................................................................................................................................................381
HASH-TABLE........................................................................................................................................................381
HASHING WITH OPEN ADDRESSING..........................................................................................................................383
HASHING WITH SEPARATE CHAINING.........................................................................................................................387
SET IMPLEMENTATION OF KOTLIN COLLECTIONS.........................................................................................................389
DICTIONARY IMPLEMENTATION IN KOTLIN COLLECTION................................................................................................389
PROBLEMS IN HASHING.........................................................................................................................................390
USES OF HASH-TABLE...........................................................................................................................................393
EXERCISE.............................................................................................................................................................393
CHAPTER 12: GRAPHS..........................................................................................................................................396
INTRODUCTION.....................................................................................................................................................396
GRAPH TERMINOLOGY...........................................................................................................................................397
GRAPH REPRESENTATION.......................................................................................................................................401
GRAPH TRAVERSALS..............................................................................................................................................404
DEPTH FIRST TRAVERSAL........................................................................................................................................405
BREADTH FIRST TRAVERSAL....................................................................................................................................407
DFS & BFS BASED PROBLEMS................................................................................................................................410
MINIMUM SPANNING TREE (MST)..........................................................................................................................426
EULER PATH AND EULER CIRCUIT.............................................................................................................................431
SHORTEST PATH ALGORITHMS IN GRAPH..................................................................................................................433
HAMILTONIAN PATH.............................................................................................................................................441
HAMILTONIAN CIRCUIT..........................................................................................................................................443
TRAVELLING SALESMAN PROBLEM (TSP)..................................................................................................................444
USES OF GRAPH ALGORITHMS.................................................................................................................................446
EXERCISE.............................................................................................................................................................446
CHAPTER 13: STRING ALGORITHMS....................................................................................................................447
INTRODUCTION.....................................................................................................................................................447
STRING MATCHING...............................................................................................................................................447
DICTIONARY / SYMBOL TABLE.................................................................................................................................451
PROBLEMS IN STRING............................................................................................................................................458
EXERCISE.............................................................................................................................................................465
CHAPTER 14: ALGORITHM DESIGN TECHNIQUES................................................................................................467
INTRODUCTION.....................................................................................................................................................467
BRUTE FORCE ALGORITHM.....................................................................................................................................467
GREEDY ALGORITHM.............................................................................................................................................468
DIVIDE AND CONQUER...........................................................................................................................................468
DYNAMIC PROGRAMMING......................................................................................................................................468
BACKTRACKING....................................................................................................................................................469
CONCLUSION.......................................................................................................................................................469
CHAPTER 15: BRUTE FORCE ALGORITHM............................................................................................................470
INTRODUCTION.....................................................................................................................................................470
PROBLEMS IN BRUTE FORCE ALGORITHM..................................................................................................................470
CONCLUSION.......................................................................................................................................................474
CHAPTER 16: GREEDY ALGORITHM.....................................................................................................................475
INTRODUCTION.....................................................................................................................................................475
PROBLEMS ON GREEDY ALGORITHM.........................................................................................................................475
CONVEX-HULL PROBLEM........................................................................................................................................489
CONCLUSION.......................................................................................................................................................491
CHAPTER 17: DIVIDE AND CONQUER..................................................................................................................492
INTRODUCTION.....................................................................................................................................................492
GENERAL DIVIDE & CONQUER RECURRENCE..............................................................................................................493
PROBLEMS ON DIVIDE & CONQUER ALGORITHM........................................................................................................493
STRASSEN’S MATRIX MULTIPLICATION......................................................................................................................499
EXERCISE.............................................................................................................................................................501
CHAPTER 18: DYNAMIC PROGRAMMING............................................................................................................503
INTRODUCTION.....................................................................................................................................................503
DYNAMIC PROGRAMMING METHODS.......................................................................................................................504
TABULATION (BOTTOM-UP)...................................................................................................................................504
MEMOIZATION (TOP-DOWN).................................................................................................................................505
DYNAMIC PROGRAMMING PATTERNS.......................................................................................................................506
TYPE 1 : MAXIMUM / MINIMUM COST TO REACH SOME STATE PROBLEMS......................................................................508
TYPE 2 : DISTINCT WAYS TO REACH SOME STATE PROBLEMS.........................................................................................513
TYPE 3 : MERGING INTERVALS TO GET OPTIMAL SOLUTION PROBLEMS............................................................................517
TYPE 4 : SUBSEQUENCE, SUBSTRINGS AND STRING MANIPULATION PROBLEMS................................................................525
TYPE 5 : STATE SELECTION KIND OF PROBLEMS..........................................................................................................534
EXERCISE.............................................................................................................................................................539
CHAPTER 19: BACKTRACKING..............................................................................................................................541
INTRODUCTION.....................................................................................................................................................541
PROBLEMS ON BACKTRACKING ALGORITHM...............................................................................................................542
EXERCISE.............................................................................................................................................................549
CHAPTER 20: COMPLEXITY THEORY.....................................................................................................................550
INTRODUCTION.....................................................................................................................................................550
DECISION PROBLEM..............................................................................................................................................550
COMPLEXITY CLASSES............................................................................................................................................550
CLASS P PROBLEMS..............................................................................................................................................551
CLASS NP PROBLEMS............................................................................................................................................552
REDUCTION.........................................................................................................................................................553
NP HARD PROBLEMS............................................................................................................................................554
NP-COMPLETE PROBLEMS.....................................................................................................................................554
CLASS CO-NP PROBLEMS.......................................................................................................................................558
END NOTE..........................................................................................................................................................558
APPENDIX............................................................................................................................................................559
CHAPTER 0: ABOUT THIS BOOK
Designing an efficient algorithm is a very important skill that all software companies pursue. Most of
the interviews for software companies are focused on knowledge of data structures and algorithms.
Apart from knowing a programming language, you also need to have a good command of these key
computer fundamentals to not only crack the interview but also excel in your jobs as a software
engineer.
Prerequisites
You should have a working knowledge of Kotlin programming language. You are not an expert in the
Kotlin language, but you are well familiar with concepts of classes, functions, references, and
recursion.
Code downloads
You can download the code of solved examples in the book from the author's GitHub repositories at
https://GitHub.com/Hemant-Jain-Author/. Hear the author had solved examples in various
programming languages like C, C++, C#, Java, Python, JavaScript, Swift, GoLang, Ruby, etc.
End
It is highly recommended that you should read the problem statement, try to solve the problems by
yourself and then only you should look into the solution to find the approach of this book. Practising
more and more problems will increase your thinking capacity, and you will be able to handle unseen
problems in an interview. We recommend you to practice all the problems given in this book, then
solve more and more problems from online resources like www.topcoder.com, www.careercup.com,
https://leetcode.com/ etc.
1
CHAPTER 1: ALGORITHMS ANALYSIS
Introduction
An Algorithm is a finite set of unambiguous steps or instructions to solve a given problem. Knowledge
of algorithms helps us to get desired results faster by applying the appropriate algorithm. We learn by
experience. With experience, it becomes easy to solve new problems. By looking into various problem-
solving algorithms or techniques, we begin to develop a pattern that will help us in solving similar
problems.
The complexity of an algorithm is the amount of Time or Space required by the algorithm to process
the input and produce the output.
In most cases, we are interested in the order of growth of the algorithm instead of the exact time
required for running an algorithm. This time is also known as Asymptotic Running Time.
Big-O Notation
Definition: “f(n) is big-O of g(n)” or f(n) = O(g(n)), if there are two +ve constants c and n1 such that f(n)
≤ c g(n) for all n ≥ n1,
2
Chapter 1: Algorithms Analysis Big-O Notation
In other words, c g(n) is an upper bound for f(n) for all n ≥ n0. The function f(n) growth is slower than c
g(n). For a sufficiently large value of input n, the (c.g(n)) will always be greater than f(n).
Omega-Ω Notation
Definition: “f(n) is omega of g(n)” or f(n)=Ω(g(n)) if there are two +ve constants c and n1 such that c
g(n) ≤ f(n) for all n ≥ n1
In other words, c g(n) is the lower bound for f(n). Function f(n) growth is faster than c g(n)
3
Chapter 1: Algorithms Analysis Theta-Θ Notation
Theta-Θ Notation
Definition: “f(n) is theta of g(n).” or f(n) = Θ(g(n)) if there are three +ve constants c1, c2 and n1 such
that c1 g(n) ≤ f(n) ≤ c2 g(n) for all n ≥ n1
Function g(n) is an asymptotically tight bound on f(n). Function f(n) grows at the same rate as g(n).
Note: Worst-case complexity is used to find the guarantee in how much time some particular algorithm
will finish. This is the most important time complexity. If the type of complexity is not mentioned, then
always consider Worst-Case time complexity.
4
Chapter 1: Algorithms Analysis Growth of functions
Growth of functions
Let’s look at these growth rates of various functions. The size of the input is n.
Examples:
1 Accessing an nth element of an Array
2 Push and pop of a stack.
3 Add and remove from a queue.
4 Accessing an element of Hash-Table.
Examples:
1 Array operations like search element, find min, find max etc.
2 Linked list operations like traversal, find min, find max etc.
Note: If we need to traverse all the nodes of a data structure for some task, then complexity cant be
less than O(n)
An example is the Binary search algorithm. We will read about this algorithm in this book.
5
Chapter 1: Algorithms Analysis Growth of functions
The time taken by certain algorithms to run varies dramatically with the size of the input. Some
algorithms take minutes or even seconds to run on huge input, whereas others may take days to
complete their execution. To understand how the rate of growth changes with the size of the input in
different functions, the following table presents the approximate number of steps required to run an
algorithm:
6
Exploring the Variety of Random
Documents with Different Content
Robespierre, 178
Rochambeau, 164, 166, 170
Rochefort, 174, 192
Rodney, Admiral, in battle with De Guichen, 155, 159–164
Roman Empire, 301
Rooke, British Admiral, 156, 157
Rosily, French Admiral, 199, 208, 221
Rotterdam, 336
Royal Sovereign, British ship, 123–217
Rozhestvensky, Russian Admiral, 66, 70, 82–84, 257, 265, 270, 274,
276–282
Russia, trade of, 25;
alliance of, 53;
in Asia, 76–78, 153, 300;
in Seven Years’ War, 147;
in Napoleonic Wars, 184–190, 192, 224–226;
a member of the Entente, 305, 317–318;
decreased strength of, 322;
her need of a navy, 327, 355–356.
See Russo-Japanese War
Russo-Japanese War, 56–57, 64, 66, 82–84, 88, 256–282, 355
Zuyder Zee, 34
1. “From Sail to Steam,” p. xiv.
2. “From Sail to Steam,” p. 55.
3. See pp. 328–341.
4. Rear Admiral Bradley A. Fiske, U. S. Naval Institute, January–February,
1915, p. 2.
5. “La Maîtrise de la Mer,” Auguste Moireau, Revue des Deux Mondes,
October, 1902.
6. “Of Kingdoms and Estates.”
7. “The Revival of Naval History,” Contemporary Review. November, 1917.
While the term “political pamphlet” suggests the influence of the book abroad, it is
obviously inappropriate in describing its purpose and method of treatment.
8. “The Kaiser’s Dreams of Sea Power,” Archibald Hurd, Fortnightly Review,
August, 1906.
9. “From Sail to Steam,” p. 303.
10. “Captain Romeo Bernotti,” letter to the editor, April 25, 1918.
11. “A Great Public Servant,” The Outlook, January 13, 1915.
12. “From Sail to Steam,” p. 288.
13. “The Influence of Sea Power upon History,” pp. 1–2, 8–10.
14. “Naval Administration and Warfare,” Objects of the Naval War College
(1888), pp. 193–194, 233–240.
15. In a preceding passage the author shows that American naval thought has
been preoccupied with problems of material.—Editor.
16. “The Influence of Sea Power upon History,” pp. 25–59. Mr. S. G. W.
Benjamin has pointed out (N. Y. Times Book Review, Feb. 2, 1902) that it was in
the preface and opening chapter of this book, “comprising only eighty-nine pages,
that Captain Mahan brought forward his famous presentation of the theory about
the influence of sea power on empire.” The present selection includes the major
part of the first chapter.—Editor.
17. For the author’s later opinion on the need of a navy, see pp. 355–357.—
Editor.
18. Written before 1890.—Editor.
19. By a base of permanent operations “is understood a country whence come
all the resources, where are united the great lines of communication by land and
water, where are the arsenals and armed posts.”
20. “Naval Administration and Warfare,” pp. 199, 206. For the distinction
drawn, see also pp. 4, 12.—Editor.
21. “Naval Strategy,” pp. 31–53.
22. An interesting instance of the method and forethought which cause
German naval development of all kinds to progress abreast, on parallel lines, is
found in the fact that by the time the three Dreadnoughts laid down in 1911 are
completed, and with them two complete Dreadnought squadrons of eight each,
which probably will be in 1914, the Kiel Canal will have been enlarged to permit
their passage. There will then be a fleet of thirty-eight battleships; including these
sixteen, which will be stationed, eight in the North Sea, eight in the Baltic, linked
for mutual support by the central canal. The programme contemplates a
continuous prearranged replacing of the present pre-Dreadnoughts by
Dreadnoughts.
23. See map on page 278.
24. “Naval Strategy,” pp. 130–163.
25. “Naval Strategy,” pp. 166–167. For illustration and further discussion of
strategic lines, see “General Strategy of the War of 1812,” in this volume, pp. 229–
240.—Editor.
26. “The Problem of Asia” (1900), pp. 124–127.
27. “Naval Strategy,” pp. 266–272.
28. “Naval Strategy,” pp. 277–280.
29. “Sea Power in its Relations to the War of 1812,” Vol. I, pp. 284–290.
30. “History of the United States,” Vol. VIII, chap. VIII.
31. “The Influence of Sea Power upon History,” p. 138.
32. This immunity of enemy property in neutral ships, guaranteed by the
Declaration of Paris in 1856, has been to a large extent nullified in recent practice
by extension of the lists of contraband, to say nothing of the violations of all law in
submarine warfare.—Editor.
33. “Naval Strategy,” pp. 303–304, 356–367, 381–382.
34. “Naval Administration and Warfare” (1903), pp. 5–11.
35. “Naval Administration and Warfare” (1903). pp. 26–31.
36. “Naval Administration and Warfare” (1903), pp. 46–48.
37. These bureaus are seven in number: Yards and Docks, Navigation,
Ordnance, Construction and Repairs, Steam Engineering, Supplies and Accounts,
and Medicine and Surgery. The Chief of Naval Operations, whose office was
created in 1915, stands second to the Secretary and acts as his expert professional
adviser, with the specific task of co-ordinating the work of the navy, preparing
plans, and directing operations in war. He is, ex officio, a member of the General
Board of the Navy, created in 1900, which serves as an expert advisory body.—
Editor.
38. “Retrospect and Prospect,” pp. 258–259, 270–272.
39. “The Interest of America in Sea Power” (1896), pp. 192–200.
40. Bombardment of undefended ports, towns, etc., is forbidden by
Convention IX of the Hague conference of 1907, with the broad concession,
however, that depots, store houses, and all constructions that serve military
purposes may be destroyed.—Editor.
41. “The Influence of Sea Power upon History” (1660–1783), pp. 197–200.
Admiral Mahan’s major historical works treat consecutively the history of naval
warfare from 1660 to 1815; and his essays and shorter studies cover subsequent
wars. The selections in Part II are arranged in chronological order.—Editor.
42. “The Influence of Sea Power upon History,” pp. 63–67.
43. An interesting proof of the weight attributed to the naval power of Great
Britain by a great military authority will be found in the opening chapter of
Jomini’s “History of the Wars of the French Revolution.” He lays down, as a
fundamental principle of European policy, that an unlimited expansion of naval
force should not be permitted to any nation which cannot be approached by land,—
a description which can apply only to Great Britain.
44. “The Influence of Sea Power upon History,” pp. 323–329. By the Treaty of
Paris, 1763, England secured Canada, all French possessions east of the
Mississippi, and Florida; she also retained Gibraltar and Minorca, and gained
ascendancy in India.—Editor.
45. See Annual Register, 1762, p. 63.
46. Campbell, “Lives of the Admirals.”
47. These remarks, always true, are doubly so now since the introduction of
steam. The renewal of coal is a want more frequent, more urgent, more
peremptory, than any known to the sailing-ship. It is vain to look for energetic
naval operations distant from coal stations. It is equally vain to acquire distant
coaling stations without maintaining a powerful navy; they will but fall into the
hands of the enemy. But the vainest of all delusions is the expectation of bringing
down an enemy by commerce-destroying alone, with no coaling stations outside
the national boundaries.
48. “Types of Naval Officers,” pp. 14–17.
49. A celebrated French admiral, in command at the battles of Beachy Head
(1690) and La Hogue (1692).—Editor.
50. The most famous of these were issued in 1665 by the Duke of York,
afterward James II, who was then Lord High Admiral. They were revised but not
greatly altered in 1740 and again in 1756.—Editor.
51. Byng’s offense, for which he was sentenced to be shot, occurred in an
action with a French squadron off Minorca in 1756.—Editor.
52. “The Influence of Sea Power upon History,” pp. 377–380.
53. De Grasse, whose victory over Graves off the Chesapeake forced the
surrender of Cornwallis, was afterward defeated by Rodney in the famous battle of
the Saints’ Passage, April 12, 1782. Three days earlier, De Grasse had neglected an
opportunity to attack in superior force.
While the battle of the Saints’ Passage is more celebrated, the action here
described better illustrates Rodney’s merits as a tactician. In his later years Rodney
wrote that he “thought little of his victory of the 12th of April,” and looked upon
this earlier action as “one by which, but for the disobedience of his captains, he
might have gained immortal renown.”—Mahan, “Types of Naval Officers,” p. 203.
—Editor.
54. The black ships, in position A, represent the English ships bearing down
upon the French center and rear. The line v r is the line of battle from van to rear
before bearing down. The positions v´, r´ are those of the van and rear ships after
hauling up on the port tack, when the French wore.—Editor.
55. In a severe reprimand addressed to Captain Carkett, commanding the
leading ship of the English line, by Rodney, he says: “Your leading in the manner
you did, induced others to follow so bad an example; and thereby, forgetting that
the signal for the line was at only two cables’ length distance from each other, the
van division was led by you to more than two leagues distance from the center
division, which was thereby exposed to the greatest strength of the enemy, and not
properly supported” (Life, Vol. I, p. 351). By all rules of tactical common-sense it
would seem that the other ships should have taken their distance from their next
astern, that is, should have closed toward the center. In conversation with Sir
Gilbert Blane, who was not in this action, Rodney stated that the French line
extended Your leagues in length, “as if De Guichen thought we meant to run away
from him” (Naval Chronicle, Vol. XXV, p. 402).
56. “The Influence of Sea Power upon History,” pp. 387–391, 397.
57. Now Cape Haitien, Haiti.—Editor.
58. Bancroft, “History of the United States.”
59. With the reinforcement brought by De Grasse, Lafayette’s army numbered
about 8,000; the troops brought by Washington and Rochambeau consisted of
2,000 Americans and 4,000 French.—Editor.
60. The action itself is more fully described in Mahan’s “Major Operations of
the Navies in the War of American Independence,” from which the diagram on
page 167 is taken. In the diagram, a a indicates the positions of the two fleets when
De Grasse came out of the bay; b b, the positions when the order to engage was
given; f, Graves’s flagship, and h, Hood. Having approached the enemy with his
twelve leading ships, Graves gave the order to bear down and engage, though he
still kept the signal for “line ahead” flying. Whether through inability or
misinterpretation of orders, the rear under Hood failed to get in range.
Hood afterward criticised his superior severely on the grounds, (1) that the
fleet was not brought into proper position to engage, and (2) that, upon engaging,
the “line ahead” signal should have been hauled down. He interpreted this signal
as meaning that no ship could close beyond a line through the flagship and parallel
to the enemy line.
Graves next day issued a memorandum to the effect that the line ahead was a
means to an end, not an end in itself, and “that the signal for battle should not be
rendered ineffective by strict adherence to the former.” The confusion was such as
frequently arose in this period of transition from one system of tactics to another.
—Editor.
61. “Types of Naval Officers,” pp. 35–37, 41.
62. Chevalier, “Mar. Fran, sous la République,” p. 49.
63. Nap. to Decrès, Aug. 29, 1805.
64. Troude, “Batailles Nav.,” Vol. III, p. 370.
65. Commodore de Rions, a member of the nobility, who was imprisoned at
Toulon and afterward fled from the country.—Editor.
66. “Types of Naval Officers,” pp. 308–317. The “Glorious First of June” is one
of the most important naval actions in the wars of the French Revolution, and
illustrates the work of an officer who stood in his own day conspicuously at the
head of his profession. The selection is interesting also as showing that, when it
suited his purpose, Admiral Mahan could write with notable ease and pictorial
vigor.—Editor.
67. “The Influence of Sea Power upon the French Revolution and Empire,”
Vol. II, pp. 42–47. The campaign is treated more fully in “The Life of Nelson,” Vol.
II, p. 70 ff.—Editor.
68. Nelson’s Letters and Dispatches, Vol. IV, p. 295.
69. Nelson’s Dispatches, Vol. IV., p. 355.
70. Nelson’s Dispatches, April 9, 1801, Vol. IV, pp. 339, 341.
71. “The Influence of Sea Power upon the French Revolution and Empire,” Vol.
II, pp. 117–120.
72. Ibid., p. 106.
73. See “Naval Chronicle,” Vol. X, pp. 508, 510; Vol. XI, p. 81; Nelson’s
Dispatches, Vol. V, p. 438.
74. Pellew’s “Life of Lord Sidmouth,” Vol. II, p. 237.
75. Nelson’s Dispatches, Vol. IV, p. 452.
76. “The Influence of Sea Power upon the French Revolution and Empire,”
Vol. II, pp. 184–197, 199–202, 356–357.
77. “The Influence of Sea Power upon the French Revolution and Empire”,
Vol. II, p. 181.
78. Napoleon to St. Cyr, Sept. 2, 1805.
79. Napoleon to Decrès, Sept. 15.
80. Ibid., Sept. 4.
81. Nelson’s Dispatches, Vol. VII, p. 80.
82. The following account of Nelson’s arrival and his plan of battle is taken
from the fuller narrative in “The Life of Nelson,” Vol. II, pp. 339–351.—Editor.
83. Inserted by author.
84. Here the narrative is resumed from “The Influence of Sea Power upon the
French Revolution and Empire.”—Editor.
85. Fyffe’s “History of Modern Europe,” Vol. I, p. 281.
86. To the King of Wurtemburg, April 2, 1811; “Corr.,” Vol. XXII, p. 19.
87. “Sea Power in its Relations with the War of 1812,” Vol. I, pp. 295–308; Vol.
II, pp. 121–125.
88. Kingsford’s “History of Canada,” Vol. VIII, p. 111.
89. Drummond to Prevost, Oct. 20, 1814. Report on Canadian Archives, 1896,
Upper Canada, p. 9.
90. Ibid., Oct. 15.
91. Prevost to Bathurst, Aug. 14, 1814. Report on Canadian Archives, 1896,
Lower Canada, p. 36.
92. “Travels,” J. M. Duncan, Vol. II, p. 27.
93. “Life of Brock,” p. 193.
94. Smyth, “Précis of the Wars in Canada,” p. 167.
95. The United States Secretary of War.—Editor.
96. December 17, 1813. Captain’s Letters, Navy Department.
97. “Lessons of the War with Spain” (1899), pp. 75–85.
98. Ibid., p. 157.
99. In this number is included the Emperador Carlos V, which, however, did
not accompany the other four under Cervera.
100. “Lessons of the War with Spain” (1899), pp. 184–191.
101. “Naval Strategy,” pp. 383–401.
102. The Kobe Chronicle, February 25, 1904; an English newspaper published
in Japan.
103. “Naval Administration and Warfare,” Retrospect upon the War between
Russia and Japan (March, 1906) pp. 167–173.
104. “Naval Strategy,” pp. 416–420.
105. “The rise or fall of the Empire depends upon to-day’s battle. Let every
man do his utmost.”—Editor.
106. “The Interest of America in Sea Power,” Hawaii and Our Future Sea
Power (1893), pp. 51–54.
107. “The Problem of Asia” (1900), pp. 133–144.
108. “The writer has been assured, by an authority in which he entirely trusts,
that to a proposition made to Great Britain (at the time of the Spanish-American
War) to enter into a combination to constrain the Use of our power,—as Japan was
five years ago constrained by the joint action of Russia, France, and Germany,—the
reply was not only a passive refusal to enter into such combination, but an
assurance of active resistance to it, if attempted.”—Mahan, “The Problem of Asia”
(1900), p. 187.—Editor.
109. “Retrospect and Prospect” (1902), pp. 15–17.
110. “The Interest of America in International Conditions,” The Open Door
(1910), pp. 198–202.
111. “The Interest of America in International Conditions” (1910), pp. 38–46.
112. The Mail, April 20, 1910.
113. “The Interest of America in International Conditions” (1910), pp. 161–164.
114. “Retrospect and Prospect,” Considerations Governing the Disposition of
Navies (1902), pp. 151–170.
115. “Naval Strategy” (1911), pp. 104–112.
116. Since this was written, a new Treaty of Alliance between Great Britain and
Japan, operative for ten years, has been signed—July 13, 1911. By its terms either
Power will be released from its military obligation to the other, as against a third
with which it may have a treaty of general arbitration, such as that framed between
Great Britain and the United States.
117. Since these words were written such formal announcement has been
made by a member of the British Cabinet, Sir Edward Grey, the Secretary for
Foreign Affairs, on May 23, 1911. The Mail, May 24, 1911.
118. “Some Neglected Aspects of War” (1907), pp. 171–191.
119. The Napoleonic Wars, the War of 1812, and the American Civil War. For
the effect of commerce warfare in these struggles, see pp. 91–99.—Editor.
120. Vol. I, pp. 146–148.
121. The “Times” of October 14, 1905.
122. Indirect, I presume.
123. “Some Neglected Aspects of War,” The Peace Conference and the Moral
Aspect of War (1899), pp. 45–52.
124. Lest this be misunderstood to be an allusion to the recent measures of
Japan in Korea, I renew here the caution that in this article all references to the
Peace Conference are to that of 1899.
125. “Some Neglected Aspects of War,” The Hague Conference and the
Practical Aspect of War (1907), pp. 75–80, 90–93.
126. “Naval Strategy,” pp. 445–447.
TRANSCRIBER’S NOTES
1. Silently corrected obvious typographical errors and
variations in spelling.
2. Retained archaic, non-standard, and uncertain spellings
as printed.
3. Re-indexed footnotes using numbers and collected
together at the end of the last chapter.
*** END OF THE PROJECT GUTENBERG EBOOK MAHAN ON
NAVAL WARFARE ***
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.