Skip to main content

Data Structures & Algorithms Learning Catalog

A Maven-organized Java repository of 70+ runnable DSA implementations indexed by category for progressive study.

5 min read·Beginner·Concept·Aug 14, 2026
projectjavaalgorithmsdata structures

Data Structures & Algorithms Learning Catalog

What Was Built

data-structure-and-algorithm is a long-running personal learning repository with 70+ Java source files covering fundamental algorithms, classic data structures, dynamic programming, and interview-style problems. Each implementation is runnable via a main method or JUnit-style execution, organized under src/main/java/zero/to/mastery/ by topic.

A comprehensive README catalog (updated August 2026) maps every file to its category, complexity (where relevant), and a one-line description — turning the repo into a navigable reference rather than a flat dump of solutions.

The Problem

Studying data structures and algorithms from random LeetCode submissions or scattered gists makes it hard to:

  • See how implementations relate (e.g., singly vs doubly vs circular linked lists).
  • Compare algorithm families (bubble vs merge vs quick sort side by side).
  • Revisit a topic months later without re-searching.

A durable learning repo needs taxonomy + runnable code + a single index.

Why This Problem Is Difficult

DSA knowledge spans many independent topics with different mental models — recursion base cases, pointer manipulation in linked lists, graph traversal state, and dynamic programming memoization tables. Without a consistent package layout and README index, the same concepts get reimplemented under inconsistent names and lost in the tree.

Beginner Mental Model

Picture a library with labeled shelves:

  • Algorithms shelf — recipes that transform or search data (sort, search, recurse).
  • Data structures shelf — containers that hold data (array, list, stack, tree).
  • Problem solving shelf — interview patterns that combine both.

The README is the card catalog. Each Java file is one book you can open and run.

Requirements and Constraints

RequirementHow the repo satisfies it
Runnable implementationsmain methods in algorithm classes
Progressive categoriesPackage per topic under zero.to.mastery
DiscoverabilityREADME tables link to every file
Standard buildMaven pom.xml with Java 11
Interview coverageClassic problems (two sum, trapping rain water, etc.)

Architecture Overview

Execution Flow

  1. Reader opens README.md and picks a topic (e.g., Merge Sort).
  2. README links to src/main/java/zero/to/mastery/algorithms/sorting/MergeSort.java.
  3. Reader runs the class main method (IDE or mvn compile exec:java).
  4. Implementation prints intermediate steps (e.g., split/merge traces in merge sort).
  5. Reader compares with adjacent algorithms in the same package (bubble, quick, etc.).

Important Components

CategoryCountRepresentative files
Array problems17TwoPairSum.java, TrappingRainWater.java, RotateMatrix90d.java
Linked lists10Singly, doubly, circular variants under linked_list/
Sorting5BubbleSort, MergeSort, QuickSort, InsertionSort, SelectionSort
Recursion7Factorial, Fibonacci, GreatestCommonDivision
Searching3BreadthFirstSearch, DepthFirstSearch, SearchNode
Hash tables7Custom hash map implementations and collision handling
Stacks / Queues6Stack, queue variants with array and linked backing
Trees / Graphs3Tree traversals, graph search support
Dynamic programming1DynamicFibonacci.java
Root-level problems8+BinarySearchTargetInArray, AlmostPalindrome, etc.

Simplified Implementation Examples

Merge sort with stable merge (simplified from source — uses <= for stability):

public static List<Integer> merge(List<Integer> left, List<Integer> right) {
List<Integer> merged = new ArrayList<>();
int leftIndex = 0, rightIndex = 0;
while (leftIndex < left.size() && rightIndex < right.size()) {
if (left.get(leftIndex) <= right.get(rightIndex)) {
merged.add(left.get(leftIndex++));
} else {
merged.add(right.get(rightIndex++));
}
}
merged.addAll(left.subList(leftIndex, left.size()));
merged.addAll(right.subList(rightIndex, right.size()));
return merged;
}

The README catalogs complexity for sorting algorithms:

AlgorithmTimeSpace
Bubble SortO(n²)O(1)
Merge SortO(n log n)O(n)
Quick SortO(n log n) avgO(log n)

Reliability and Idempotency

Each class is self-contained with its own main method. Running one file does not mutate shared state across other files. There is no shared database or service — correctness is local to each implementation.

Failure Modes

FailureDetectionRecovery
Stale README link404 in GitHub UIUpdate README when moving/renaming files
Off-by-one in binary searchWrong index returnedCompare with BinarySearchStartAndEndOfTarget variant
Unstable merge sortEqual elements reorderUse <= not < in merge comparison
Linked list cycleInfinite loopCircular list examples document cycle detection

Trade-offs and Rejected Alternatives

DecisionRationaleRejected alternative
One class per conceptEasy to run and share individuallySingle mega-class with all algorithms
README as catalogZero build step to browse topicsGenerated docs site (heavier setup)
Java 11 + MavenFamiliar interview languageMulti-language polyglot repo
Verbose println tracingTeaches algorithm stepsSilent implementations
Lombok dependencyLess boilerplate in data classesPure Java POJOs everywhere

Testing

JUnit 4 is listed as a dependency in pom.xml. Many files use main methods for demonstration rather than formal test classes. The repo prioritizes readable execution traces over comprehensive test coverage.

Operations and Observability

git clone https://github.com/okfriansyah-moh/data-structure-and-algorithm.git
cd data-structure-and-algorithm
mvn compile
# Run individual classes from your IDE or:
mvn -q exec:java -Dexec.mainClass="zero.to.mastery.algorithms.sorting.MergeSort"

Requires Java 11+ and Maven.

Lessons Learned

  1. A README catalog is the cheapest navigation layer — 70 files stay usable when every file has a table row with a link and description.
  2. Package by topic, not by datealgorithms/sorting/ beats week3/ for recall.
  3. Print intermediate states — merge sort's split/merge logs teach divide-and-conquer better than a final sorted array alone.
  4. Keep interview problems near their data structureTwoPairSum lives under arrays/, not a separate "leetcode" dump.

Sources