https://github.com/myronrotter/recap-java-algorithms
Recap and re-implement common-used and well-known algorithms in Java.
https://github.com/myronrotter/recap-java-algorithms
algorithms java java-8 searching-algorithms sorting-algorithms
Last synced: about 2 months ago
JSON representation
Recap and re-implement common-used and well-known algorithms in Java.
- Host: GitHub
- URL: https://github.com/myronrotter/recap-java-algorithms
- Owner: myronrotter
- License: mit
- Created: 2020-01-04T11:43:01.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-26T13:09:07.000Z (over 6 years ago)
- Last Synced: 2025-04-13T00:26:00.994Z (about 1 year ago)
- Topics: algorithms, java, java-8, searching-algorithms, sorting-algorithms
- Language: Java
- Homepage:
- Size: 76.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Recap java algorithms
Main purpose of this project is to recap and re-implement common-used and well-known algorithms in Java and their properties as well as getting used to Maven, EditorConfig and GitHub actions/ workflows. Properties of implemented algorithms may differ from properties listed below. Some algorithms are plain implementations of common-known pseudocode.
## Sorting
| class | name | best-case | average-case | worst-case | description | in-place | stable |
| ------------ | --------------- | -------------------- | -------------------- | --------------- | ----------------------------------- | ------------------------------ | ------ |
| insertion | InsertionSort | $\Omega(n)$ | $\Theta(n^2)$ | $O(n^2)$ | | Yes | Yes |
| | ShellSort[^1] | $\Omega(n * log(n))$ | $\Theta(n * log(n))$ | $O(n^2)$ | | Yes | No |
| selection | SelectionSort | $\Omega(n^2)$ | $\Theta(n^2)$ | $O(n^2)$ | | Yes | No |
| | HeapSort | $\Omega(n * log(n))$ | $\Theta(n * log(n))$ | $O(n * log(n))$ | | Yes | No |
| exchange | BubbleSort | $\Omega(n)$ | $\Theta(n^2)$ | $O(n^2)$ | | Yes | Yes |
| | CombSort[^1] | $\Omega(n * log(n))$ | $\Theta(n^2/2^p)$ | $O(n^2)$ | $p$ the number of increments | Yes | No |
| | CocktailSort | $\Omega(n)$ | $\Theta(n^2)$ | $O(n^2)$ | | Yes | Yes |
| | QuickSort | $\Omega(n * log(n))$ | $\Theta(n * log(n))$ | $O(n^2)$ | | Yes | No |
| | GnomeSort | $\Omega(n)$ | $\Theta(n^2)$ | $O(n^2)$ | | Yes | Yes |
| | BogoSort | $\Omega(n)$ | $\Theta(n * n!)$ | $infinitly$ | | Yes | No |
| merge | MergeSort | $\Omega(n * log(n))$ | $\Theta(n * log(n))$ | $O(n * log(n))$ | | No (uses auxillary storage) | Yes |
| distribution | CountingSort | $\Omega(n+k)$ | $\Theta(n+k)$ | $O(n+k)$ | $k$ the range of the input interval | No (uses auxillary storage) | Yes |
| | BucketSort | $\Omega(n+b)$ | $\Theta(n+b)$ | $O(n^2)$ | $b$ the number of buckets | No (uses auxillary storage) | No |
| concurrent | BitonicSort[^2] | $\Omega(log^2(n))$ | $\Theta(log^2(n))$ | $O(log^2(n))$ | | No (depends on implementation) | No |
| hybrid | | | | | | | |
| other | PancakeSort | | $\Theta(n^2)$ | $O(n^2)$ | | Yes | No |
## Searching
| class | name | best-case | average-case | worst-case | description |
| ------------------- | ----------------------------- | ----------- | ------------------------- | ------------- | ---------------------------------- |
| generic (Searching) | LinearSearch | $\Omega(1)$ | $\Theta(n)$ | $O(n)$ | |
| | BinarySearch | $\Omega(1)$ | $\Theta(log(n))$ | $O(log(n))$ | |
| | TernarySearch | $\Omega(1)$ | $\Theta(log_3(n))$ | $O(log_3(n))$ | |
| | JumpSearch | $\Omega(1)$ | $\Theta(\sqrt{n})$ | $O(\sqrt{n})$ | |
| | ExponentialSearch | $\Omega(1)$ | $\Theta(log(n))$ | $O(log(n))$ | |
| | FibonacciSearch | $\Omega(1)$ | $\Theta(log(n))$ | $O(log(n))$ | |
| 2D (Searching2D) | SaddlebackSearch | $\Omega(1)$ | $\Theta(n+m)$ | $O(n+m)$ | $m$ the maximum of all rows length |
| integer (Finding) | InterpolationSearch | $\Omega(1)$ | $\Theta(log(log(n)))$[^3] | $O(n)$ | |
| | InterpolationSequentialSearch | | | | |
[^1]: Strictly, it depends on gap sequence/ size.
[^2]: Denoted is the delay within the network of $O(n * log^2(n))$ comparators.
[^3]: E.g. the elements are uniformly distributed.