java-algorithms-implementation
repository·master·Indexed 26 days ago
https://github.com/phishman3579/java-algorithms-implementationA comprehensive Java implementation of various algorithms and data structures. The library covers data structures (Trees, Maps, Linear Structures), mathematics and number theory, graph algorithms (Shortest Path, Spanning Trees, Flow & Matching), search and sort algorithms, and string manipulations including Manacher's and Knuth-Morris-Pratt algorithms.
What's inside java-algorithms-implementation
- This repository is a collection of algorithms and data structures implemented in Java. The implementations are designed for correctness and readability rather than extreme optimization. The library covers a wide range of computer science topics including data structures, mathematics, number theory, graph theory, search algorithms, sequences, and sorting algorithms.
Use StringFunctions for common string manipulations
masterThe
StringFunctionsclass provides various implementations for common string-based algorithms. Available operations include:- Reversing characters: Supports implementations using additional storage (String/StringBuilder), in-place swaps, and in-place XOR.
- Reversing words: Supports implementations using char swaps with StringBuilder,
StringTokenizer, thesplit()method, and in-place swaps. - Palindrome checks: Supports implementations using additional storage (StringBuilder) or in-place symmetric element comparisons.
- Subsets: Find subsets of characters in a String.
- Edit Distance: Calculates the Levenshtein distance between two strings using both Recursive and Iterative approaches.
Calculate prefix-suffix lengths using KMP Algorithm
masterTheKnuthMorrisPrattclass implements the Knuth–Morris–Pratt (KMP) algorithm to determine the length of the maximal prefix-suffix for each prefix of a string.Find lexicographical string rotations
masterThe
Rotationclass provides utilities to find specific string rotations:- Find the lexicographically minimal string rotation.
- Find the lexicographically maximal string rotation.
Find the longest palindrome using Manacher's algorithm
masterUse theManacherclass to find the longest palindromic substring within a given string using Manacher's algorithm.Reference of implemented Mathematics and Number algorithms
masterMathematical and numerical algorithms are available in the
com.jwetherell.algorithms.mathematicsandcom.jwetherell.algorithms.numberspackages:- Mathematics: Distance (Chebyshev, Euclidean), Division (various methods), Multiplication (including Fast Fourier Transform), Exponentiation, Primes (Sieve of Eratosthenes, Miller-Rabin, etc.), Permutations, Modular Arithmetic, Knapsack, Ramer Douglas Peucker.
- Numbers: Integers (binary conversion, power of 2 checks, English conversion), Longs (binary conversion), Complex (arithmetic and polar values).
Reference of implemented Graph algorithms
masterGraph algorithms are available in the
com.jwetherell.algorithms.graphpackage:- Shortest Path: Dijkstra's, Bellman-Ford, Johnsons', Floyd-Warshall, A*.
- Spanning Trees: Prim's, Kruskal's.
- Traversal & Connectivity: Depth First Traversal, Breadth First Traversal, Cycle Detection, Connected Components, Topological Sort.
- Flow & Matching: Push-Relabel, Edmonds Karp, Turbo Matching.
Reference of implemented Search and Sort algorithms
masterSearch and Sort algorithms are available in the
com.jwetherell.algorithms.searchandcom.jwetherell.algorithms.sortspackages:- Search: Linear Search, Quickselect, Binary Search, Lower Bound, Upper Bound, Interpolation Search.
- Sorts: American Flag Sort, Bubble Sort, Counting Sort, Heap Sort, Insertion Sort, Merge Sort, Quick Sort, Radix Sort, Shell's Sort.
- Sequences: Longest Common Subsequence, Longest Increasing Subsequence, Subsequence Counter, Fibonacci Sequence, Arithmetic Progression, Largest Sum Contiguous Subarray (Kadane's), Longest Palindromic Subsequence.
Reference of implemented Data Structures
masterThe following data structures are available in the
com.jwetherell.algorithms.data_structurespackage:- Trees: AVL Tree, B-Tree, Binary Search Tree, Compact Suffix Trie, Fenwick Tree (BIT), Interval Tree, Implicit Key Treap, KD Tree, Patricia Trie, Quad-Tree, Red-Black Tree, Segment Tree, Splay Tree, Suffix Array, Suffix Tree, Suffix Trie, Ternary Search Tree, Treap, Tree, Trie, Trie Map.
- Maps/Associative Arrays: Hash Map, Hash Array Mapped Trie (HAMT), Radix Trie, TreeMap, Trie Map.
- Linear Structures: Binary Heap, Disjoint Set, List, Matrix, Queue, Skip List, Stack, Suffix Array.
- Other: Graph (Undirected/Directed).