@@ -5,7 +5,22 @@ Algorithms and Data Structures implemented in Java
5
5
6
6
This is a collection of algorithms and data structures which I've implement over the years in my academic and professional life. The code isn't overly-optimized but is written to be correct and readable. The algorithms and data structures are well tested and, unless noted, are believe to be 100% correct.
7
7
8
+ <<<<<<< HEAD
8
9
* Created by Justin Wetherell
10
+ =======
11
+ ## Table of Contents
12
+ - [ Data Structures] ( #data-structures )
13
+ - [ Mathematics] ( #mathematics )
14
+ - [ Numbers] ( #numbers )
15
+ - [ Graphs] ( #graphs )
16
+ - [ Search] ( #search )
17
+ - [ Sequences] ( #sequences )
18
+ - [ Sorts] ( #sorts )
19
+ - [ String Functions] ( #string-functions )
20
+
21
+ ## * Created by Justin Wetherell
22
+
23
+ >>>>>>> c0d476f8e48bd15f03ff6c83905785ddd922e873
9
24
* For questions use: http://groups.google.com/forum/#!forum/java-algorithms-implementation
10
25
* Google: http://code.google.com/p/java-algorithms-implementation
11
26
* Github: http://github.com/phishman3579/java-algorithms-implementation
@@ -20,6 +35,7 @@ This is a collection of algorithms and data structures which I've implement over
20
35
# What's been implemented:
21
36
22
37
## Data Structures
38
+ <<<<<<< HEAD
23
39
* AVL Tree
24
40
* B-Tree
25
41
* Binary Heap [ backed by an array or a tree]
@@ -58,16 +74,61 @@ This is a collection of algorithms and data structures which I've implement over
58
74
+ chebyshev
59
75
+ euclidean
60
76
* Division
77
+ =======
78
+ * [ AVL Tree] ( src/com/jwetherell/algorithms/data_structures/AVLTree.java )
79
+ * [ B-Tree] ( src/com/jwetherell/algorithms/data_structures/BTree.java )
80
+ * [ Binary Heap (backed by an array or a tree)] ( src/com/jwetherell/algorithms/data_structures/BinaryHeap.java )
81
+ * [ Binary Search Tree] ( src/com/jwetherell/algorithms/data_structures/BinarySearchTree.java )
82
+ * [ Compact Suffix Trie (backed by a Patricia Trie)] ( src/com/jwetherell/algorithms/data_structures/CompactSuffixTrie.java )
83
+ * [ Disjoint Set] ( src/com/jwetherell/algorithms/data_structures/DisjointSet.java )
84
+ * [ Fenwick Tree {Binary Indexed Tree (BIT)}] ( src/com/jwetherell/algorithms/data_structures/FenwickTree.java )
85
+ * [ Graph] ( src/com/jwetherell/algorithms/data_structures/Graph.java )
86
+ + Undirected
87
+ + Directed (Digraph)
88
+ * [ Hash Array Mapped Trie (HAMT)] ( src/com/jwetherell/algorithms/data_structures/HashArrayMappedTrie.java )
89
+ * [ Hash Map (associative array)] ( src/com/jwetherell/algorithms/data_structures/HashMap.java )
90
+ * [ Interval Tree] ( src/com/jwetherell/algorithms/data_structures/IntervalTree.java )
91
+ * [ Implicit Key Treap] ( (src/com/jwetherell/algorithms/data_structures/ImplicitKeyTreap.java) )
92
+ * [ KD Tree (k-dimensional tree or k-d tree)] ( src/com/jwetherell/algorithms/data_structures/KDTree.java )
93
+ * [ List [ backed by an array or a linked list]] ( (src/com/jwetherell/algorithms/data_structures/List.java) )
94
+ * [ Matrix] ( src/com/jwetherell/algorithms/data_structures/Matrix.java )
95
+ * [ Patricia Trie] ( src/com/jwetherell/algorithms/data_structures/PatriciaTrie.java )
96
+ * [ Quad-Tree (Point-Region or MX-CIF)] ( src/com/jwetherell/algorithms/data_structures/QuadTree.java )
97
+ * [ Queue [ backed by an array or a linked list]] ( src/com/jwetherell/algorithms/data_structures/Queue.java )
98
+ * [ Radix Trie (associative array) [ backed by a Patricia Trie]] ( src/com/jwetherell/algorithms/data_structures/RadixTree.java )
99
+ * [ Red-Black Tree] ( src/com/jwetherell/algorithms/data_structures/RedBlackTree.java )
100
+ * [ Segment Tree] ( src/com/jwetherell/algorithms/data_structures/SegmentTree.java )
101
+ * [ Skip List] ( src/com/jwetherell/algorithms/data_structures/SkipList.java )
102
+ * [ Splay Tree] ( src/com/jwetherell/algorithms/data_structures/SplayTree.java )
103
+ * [ Stack [ backed by an array or a linked list]] ( src/com/jwetherell/algorithms/data_structures/Stack.java )
104
+ * [ Suffix Tree (Ukkonen's algorithm)] ( src/com/jwetherell/algorithms/data_structures/SuffixTree.java )
105
+ * [ Suffix Trie [ backed by a Trie]] ( src/com/jwetherell/algorithms/data_structures/SufficTrie.java )
106
+ * [ Treap] ( src/com/jwetherell/algorithms/data_structures/Treap.java )
107
+ * [ Tree Map (associative array) [ backed by an AVL Tree]] ( src/com/jwetherell/algorithms/data_structures/TreeMap.java )
108
+ * [ Trie] ( src/com/jwetherell/algorithms/data_structures/Trie.java )
109
+ * [ Trie Map (associative array) [ backed by a Trie]] ( src/com/jwetherell/algorithms/data_structures/TrieMap.java )
110
+
111
+ ## Mathematics
112
+ * [ Distance] ( src/com/jwetherell/algorithms/mathematics/Distance.java )
113
+ + chebyshev
114
+ + euclidean
115
+ * [ Division] ( src/com/jwetherell/algorithms/mathematics/Division.java )
116
+ >>>>>>> c0d476f8e48bd15f03ff6c83905785ddd922e873
61
117
+ using a loop
62
118
+ using recursion
63
119
+ using shifts and multiplication
64
120
+ using only shifts
65
121
+ using logarithm
122
+ <<<<<<< HEAD
66
123
* Multiplication
124
+ =======
125
+ * [ Multiplication] ( src/com/jwetherell/algorithms/mathematics/Multiplication.java )
126
+ >>>>>>> c0d476f8e48bd15f03ff6c83905785ddd922e873
67
127
+ using a loop
68
128
+ using recursion
69
129
+ using only shifts
70
130
+ using logarithms
131
+ <<<<<<< HEAD
71
132
+ using FFT
72
133
* Primes
73
134
+ is prime
@@ -81,14 +142,37 @@ This is a collection of algorithms and data structures which I've implement over
81
142
+ strings
82
143
+ numbers
83
144
* Modular arithmetic
145
+ =======
146
+ + [ Fast Fourier Transform] ( src/com/jwetherell/algorithms/mathematics/FastFourierTransform.java )
147
+ * [ Primes] ( src/com/jwetherell/algorithms/mathematics/Primes.java )
148
+ + is prime
149
+ + prime factorization
150
+ + sieve of eratosthenes
151
+ + [ Co-Primes (relatively prime, mutually prime)] ( src/com/jwetherell/algorithms/mathematics/Coprimes.java )
152
+ + [ Greatest Common Divisor] ( src/com/jwetherell/algorithms/mathematics/GreatestCommonDivisor.java )
153
+ - using Euclid's algorithm
154
+ - using recursion
155
+ * [ Permutations] ( src/com/jwetherell/algorithms/mathematics/Permutations.java )
156
+ + strings
157
+ + numbers
158
+ * [ Modular arithmetic] ( src/com/jwetherell/algorithms/mathematics/Modular.java )
159
+ >>>>>>> c0d476f8e48bd15f03ff6c83905785ddd922e873
84
160
+ add
85
161
+ subtract
86
162
+ multiply
87
163
+ divide
88
164
+ power
165
+ <<<<<<< HEAD
89
166
90
167
## Numbers
91
168
* Integers
169
+ =======
170
+ * [ Knapsack] ( src/com/jwetherell/algorithms/mathematics/Knapsack.java )
171
+ * [ Ramer Douglas Peucker] ( src/com/jwetherell/algorithms/mathematics/RamerDouglasPeucker.java )
172
+
173
+ ## Numbers
174
+ * [ Integers] ( src/com/jwetherell/algorithms/numbers/Integers.java )
175
+ >>>>>>> c0d476f8e48bd15f03ff6c83905785ddd922e873
92
176
+ to binary String
93
177
- using divide and modulus
94
178
- using right shift and modulus
@@ -100,12 +184,20 @@ This is a collection of algorithms and data structures which I've implement over
100
184
- using logarithm
101
185
- using bits
102
186
+ to English (e.g. 1 would return "one")
187
+ <<<<<<< HEAD
103
188
* Longs
189
+ =======
190
+ * [ Longs] ( src/com/jwetherell/algorithms/numbers/Longs.java )
191
+ >>>>>>> c0d476f8e48bd15f03ff6c83905785ddd922e873
104
192
+ to binary String
105
193
- using divide and modulus
106
194
- using right shift and modulus
107
195
- using BigDecimal
196
+ <<<<<<< HEAD
108
197
* Complex
198
+ =======
199
+ * [ Complex] ( src/com/jwetherell/algorithms/numbers/Complex.java )
200
+ >>>>>>> c0d476f8e48bd15f03ff6c83905785ddd922e873
109
201
+ addition
110
202
+ subtraction
111
203
+ multiplication
@@ -114,6 +206,7 @@ This is a collection of algorithms and data structures which I've implement over
114
206
115
207
## Graphs
116
208
* Find shortest path(s) in a Graph from a starting Vertex
209
+ <<<<<<< HEAD
117
210
- Dijkstra's algorithm (non-negative weight graphs)
118
211
- Bellman-Ford algorithm (negative and positive weight graphs)
119
212
* Find minimum spanning tree
@@ -144,10 +237,47 @@ This is a collection of algorithms and data structures which I've implement over
144
237
* Find longest increasing subsequence (dynamic programming)
145
238
* Find number of times a subsequence occurs in a sequence (dynamic programming)
146
239
* Find i-th element in a Fibonacci sequence
240
+ =======
241
+ - [ Dijkstra's algorithm (non-negative weight graphs)] ( src/com/jwetherell/algorithms/graph/Dijkstra.java )
242
+ - [ Bellman-Ford algorithm (negative and positive weight graphs)] ( src/com/jwetherell/algorithms/graph/BellmanFord.java )
243
+ * Find minimum spanning tree
244
+ - [ Prim's (undirected graphs)] ( src/com/jwetherell/algorithms/graph/Prim.java )
245
+ - [ Kruskal's (undirected graphs)] ( src/com/jwetherell/algorithms/graph/Kruskal.java )
246
+ * Find all pairs shortest path
247
+ - [ Johnsons's algorithm (negative and positive weight graphs)] ( src/com/jwetherell/algorithms/graph/Johnsons.java )
248
+ - [ Floyd-Warshall (negative and positive weight graphs)] ( src/com/jwetherell/algorithms/graph/FloydWarshall.java )
249
+ * [ Cycle detection] ( src/com/jwetherell/algorithms/graph/CycleDetection.java )
250
+ - Depth first search while keeping track of visited Verticies
251
+ - [ Connected Components] ( src/com/jwetherell/algorithms/graph/ConnectedComponents.java )
252
+ * [ Topological sort] ( src/com/jwetherell/algorithms/graph/TopologicalSort.java )
253
+ * [ A* path finding algorithm] ( src/com/jwetherell/algorithms/graph/AStar.java )
254
+ * Maximum flow
255
+ - [ Push-Relabel] ( src/com/jwetherell/algorithms/graph/PushRelabel.java )
256
+ * Graph Traversal
257
+ - [ Depth First Traversal] ( src/com/jwetherell/algorithms/graph/DepthFirstTravesal.java )
258
+ * [ Edmonds Karp] ( src/com/jwetherell/algorithms/graph/EdmondsKarp.java )
259
+
260
+ ## Search
261
+ * Get index of value in array
262
+ + [ Linear] ( src/com/jwetherell/algorithms/Sequences/LinearSearch.java )
263
+ + [ Quickselect] ( src/com/jwetherell/algorithms/Sequences/QuickSelect.java )
264
+ + [ Binary [ sorted array input only]] ( src/com/jwetherell/algorithms/Sequences/BinarySearch.java )
265
+ + [ Lower bound [ sorted array input only]] ( src/com/jwetherell/algorithms/Sequences/LpperBound.java )
266
+ + [ Upper bound [ sorted array input only]] ( src/com/jwetherell/algorithms/Sequences/UpperBound.java )
267
+ + Optimized binary (binary until a threashold then linear) [ sorted array input only]
268
+ + [ Interpolation [ sorted array input only]] ( src/com/jwetherell/algorithms/Sequences/InterpolationSearch.java )
269
+
270
+ ## Sequences
271
+ * [ Find longest common subsequence (dynamic programming)] ( src/com/jwetherell/algorithms/Sequences/LongestCommonSubsequence.java )
272
+ * [ Find longest increasing subsequence (dynamic programming)] ( src/com/jwetherell/algorithms/Sequences/LongestIncreasingSubsequence.java )
273
+ * [ Find number of times a subsequence occurs in a sequence (dynamic programming)] ( src/com/jwetherell/algorithms/Sequences/SubsequenceCounter.java )
274
+ * [ Find i-th element in a Fibonacci sequence] ( src/com/jwetherell/algorithms/Sequences/FibonacciSequence.java )
275
+ >>>>>>> c0d476f8e48bd15f03ff6c83905785ddd922e873
147
276
+ using a loop
148
277
+ using recursion
149
278
+ using matrix multiplication
150
279
+ using Binet's formula
280
+ <<<<<<< HEAD
151
281
* Find total of all elements in a sequence
152
282
+ using a loop
153
283
+ using Triangular numbers
@@ -166,6 +296,27 @@ This is a collection of algorithms and data structures which I've implement over
166
296
* Shell's Sort
167
297
168
298
## String Functions
299
+ =======
300
+ * [ Find total of all elements in a sequence(Arithmetic Progression)] ( src/com/jwetherell/algorithms/Sequences/ArithmeticProgression.java )
301
+ + using a loop
302
+ + using Triangular numbers
303
+ * [ Largest sum of contiguous subarray (Kadane's algorithm)] ( src/com/jwetherell/algorithms/Sequences/LargestSumContiguousSubarray.java )
304
+ * [ Longest palindromic subsequence (dynamic programming)] ( src/com/jwetherell/algorithms/Sequences/LongestPalindromicSubsequence.java )
305
+
306
+ ## Sorts
307
+ * [ American Flag Sort] ( src/com/jwetherell/algorithms/Sorts/AmericanFlagSort.java )
308
+ * [ Bubble Sort] ( src/com/jwetherell/algorithms/Sorts/BubbleSort.java )
309
+ * [ Counting Sort (Integers only)] ( src/com/jwetherell/algorithms/Sorts/CountingSort.java )
310
+ * [ Heap Sort] ( src/com/jwetherell/algorithms/Sorts/HeapSort.java )
311
+ * [ Insertion Sort] ( src/com/jwetherell/algorithms/Sorts/InsertionSort.java )
312
+ * [ Merge Sort] ( src/com/jwetherell/algorithms/Sorts/AMergeSort.java )
313
+ * [ Quick Sort] ( src/com/jwetherell/algorithms/Sorts/QuickSort.java )
314
+ * [ Radix Sort (Integers only)] ( src/com/jwetherell/algorithms/Sorts/RadixSort.java )
315
+ * [ Shell's Sort] ( src/com/jwetherell/algorithms/Sorts/ShellSort.java )
316
+
317
+ ## String Functions
318
+ ### [ String Functions] ( src/com/jwetherell/algorithms/strings/StringFunctions.java )
319
+ >>>>>>> c0d476f8e48bd15f03ff6c83905785ddd922e873
169
320
* Reverse characters in a string
170
321
+ using additional storage (a String or StringBuilder)
171
322
+ using in-place swaps
@@ -180,8 +331,13 @@ This is a collection of algorithms and data structures which I've implement over
180
331
+ using in-place symetric element compares
181
332
* Subsets of characters in a String
182
333
* Edit (Levenshtein) Distance of two Strings
334
+ <<<<<<< HEAD
183
335
* KMP (Knuth–Morris–Pratt) Algorithm - Length of maximal prefix-suffix for each prefix
184
336
* String rotations
337
+ =======
338
+ * [ KMP (Knuth–Morris–Pratt) Algorithm - Length of maximal prefix-suffix for each prefix] ( src/com/jwetherell/algorithms/strings/KnuthMorrisPratt.java )
339
+ * [ String rotations] ( src/com/jwetherell/algorithms/strings/Rotation.java )
340
+ >>>>>>> c0d476f8e48bd15f03ff6c83905785ddd922e873
185
341
+ Findin lexicographically minimal string rotation
186
342
+ Findin lexicographically maximal string rotation
187
343
0 commit comments