What’s inside.
Each chapter has a complete program to run, the time and memory cost, and exercises.
- 00
Install a JDK and prepare your workspace
Set up Java 25 (or any JDK from 17), a terminal and an editor, and run your first program.
- 01
Java foundations for DSA
Types, arrays, loops and methods, plus the integer overflow and division rules algorithms depend on.
- 02
Arrays, lists, maps and sets
Choose between arrays, ArrayList, HashMap and HashSet, and meet autoboxing.
- 03
Strings, chars and code points
Why length() counts UTF-16 units, and how to build strings without quadratic copying.
- 04
Classes, records and references
Build nodes with classes, data with records, and reason about shared references.
- 05
Recursion
Base cases, smaller problems, and the stack depth that ends in StackOverflowError.
- 06
- 07
- 08
Hash tables, equals and hashCode
How a key finds its bucket, what a collision costs, and the contract every key must keep.
See hash tables visualized - 09
Trees, binary search trees and TreeMap
Traverse and search a BST, see it degrade, and use TreeMap for guaranteed log n.
See trees visualized - 10
Heaps and PriorityQueue
Implement a min-heap, then use PriorityQueue without its ordering surprises.
See heaps visualized - 11
Searching and sorting
Binary search without overflow or off-by-one mistakes, and what Arrays.sort guarantees.
- 12
Two pointers, sliding windows and prefix sums
Stop rescanning the same elements, with half-open ranges and long sums.
- 13
Divide and conquer and backtracking
Count inversions by merging, and explore choices while undoing each one cleanly.
- 14
Graph traversal with BFS and DFS
Represent a graph with adjacency lists, visit each vertex once, and recover a shortest path.
See graph traversal visualized - 15
Greedy algorithms and their limits
When the locally best choice is globally best, and a counterexample when it is not.
- 16
Dynamic programming
Define a state, write the recurrence, and pick sentinels and types that cannot overflow.
- 17
Mixed practice and a small Java project
Choose a technique without a chapter title to help, and build a dependency planner.
Prefer another language? Go for DSA, JavaScript for DSA, Python for DSA or C++ for DSA.