This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
A pure Java repository of hand-written data structure implementations and LeetCode solutions. There is no build tool (no Maven/Gradle) — source files are compiled and run directly via javac/java from the src/ root.
Compile and run from the src/ directory:
cd src
javac com/ds_algo/z_sorts/TestMain.java # compile a Main class (pulls in dependencies)
java com.ds_algo.z_sorts.TestMain # run itEach data structure package has its own Main or Test*Main class as an entry point. There is no test framework — verification is done by running these main classes.
All source lives under src/com/:
-
ds_algo/— Data structures, alphabetically prefixed (a_throughz_), each self-contained:- Linear: ArrayList, LinkedList (single, circular), Stack, Queue (circular, deque)
- Trees: BST → BinaryTree → BBST → AVLTree / RBTree (inheritance chain in
f_BST/,g_AVLTree/,h_RBTree/) - Collections: Set (List/Tree), Map (TreeMap), HashMap (red-black tree buckets with
LinkedHashMap), HashSet - Advanced: Heap, PriorityQueue, Huffman coding, Trie, UnionFind (multiple optimization variants), Graph (adjacency list with BFS/DFS/Dijkstra/Bellman-Ford/Floyd/Prim/Kruskal/topological sort)
- Sorting:
z_sorts/— abstractSort<T>base class with comparison sorts (cmp/) and non-comparison sorts (Counting, Radix, Bucket)
-
leetcode/— LeetCode solutions organized by topic (array, binaryTree, dfs, dp, graph, linkedList, priorityQueue, queue, stack). File naming:_<number>_<Chinese description>.java. -
tool/— Shared utilities:binaryTree/printer/— Binary tree pretty-printer (implementsBinaryTreeInfointerface)common/—Asserts,Integers(random array generation),TimeTool, file utilities
- The tree hierarchy uses a layered inheritance:
BinaryTree→BST→BBST→AVLTree/RBTree. Adding a new balanced tree means extendingBBST. Sort<T>is an abstract base that tracks compare/swap counts and timing. Concrete sorts override thesort()template method.SortFactorycreates sort instances for benchmarking.Graph<V, E>is abstract with aWeightManager<E>strategy for generic edge weights.ListGraphis the adjacency-list implementation.HashMapuses red-black tree nodes for collision resolution (not linked lists), defined inline asHashMap.Node.- UnionFind has progressive optimization variants: QF → QU → QU+Size → QU+Rank → QU+Rank+PathCompression/PathHalving/PathSplitting.
UnionFindGeneric<V>wraps int-based UnionFind for arbitrary value types.
Comments and class names are in Chinese. LeetCode file names use Chinese descriptions after the problem number.