Skip to content

Commit 39fb790

Browse files
authored
Update README.md
1 parent da58e6b commit 39fb790

File tree

1 file changed

+20
-194
lines changed

1 file changed

+20
-194
lines changed

README.md

Lines changed: 20 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -1,194 +1,20 @@
1-
# The Algorithms - Java
2-
3-
### All algorithms implemented in Java (for education)
4-
5-
These are for demonstration purposes only. There are many implementations of sorts in the Java standard library that are much better for performance reasons.
6-
7-
## Sort Algorithms
8-
9-
10-
### Bubble
11-
![alt text][bubble-image]
12-
13-
From [Wikipedia][bubble-wiki]: Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted.
14-
15-
__Properties__
16-
* Worst case performance O(n^2)
17-
* Best case performance O(n)
18-
* Average case performance O(n^2)
19-
20-
###### View the algorithm in [action][bubble-toptal]
21-
22-
23-
24-
### Insertion
25-
![alt text][insertion-image]
26-
27-
From [Wikipedia][insertion-wiki]: Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort.
28-
In the figure, each bar represents an element of an array that needs to be sorted. What happens at the first intersection of the top most and second top most bars is to swap these elements, represented by bars, because the second element has a higher precedence than the first element does. By repeating this method, insertion sort completes sorting.
29-
30-
__Properties__
31-
* Worst case performance O(n^2)
32-
* Best case performance O(n)
33-
* Average case performance O(n^2)
34-
35-
###### View the algorithm in [action][insertion-toptal]
36-
37-
38-
### Merge
39-
![alt text][merge-image]
40-
41-
From [Wikipedia][merge-wiki]: In computer science, merge sort (also commonly spelt mergesort) is an efficient, general-purpose, comparison-based sorting algorithm. Most implementations produce a stable sort, which means that the implementation preserves the input order of equal elements in the sorted output. Mergesort is a divide and conquer algorithm that was invented by John von Neumann in 1945.
42-
43-
__Properties__
44-
* Worst case performance O(n log n) (typical)
45-
* Best case performance O(n log n)
46-
* Average case performance O(n log n)
47-
48-
49-
###### View the algorithm in [action][merge-toptal]
50-
51-
### Quick
52-
![alt text][quick-image]
53-
54-
From [Wikipedia][quick-wiki]: Quicksort (sometimes called partition-exchange sort) is an efficient sorting algorithm, serving as a systematic method for placing the elements of an array in order.
55-
56-
__Properties__
57-
* Worst case performance O(n^2)
58-
* Best case performance O(n log n) or O(n) with three-way partition
59-
* Average case performance O(n^2)
60-
61-
###### View the algorithm in [action][quick-toptal]
62-
63-
### Selection
64-
![alt text][selection-image]
65-
66-
From [Wikipedia][selection-wiki]: The algorithm divides the input list into two parts: the sublist of items already sorted, which is built up from left to right at the front (left) of the list, and the sublist of items remaining to be sorted that occupy the rest of the list. Initially, the sorted sublist is empty and the unsorted sublist is the entire input list. The algorithm proceeds by finding the smallest (or largest, depending on sorting order) element in the unsorted sublist, exchanging (swapping) it with the leftmost unsorted element (putting it in sorted order), and moving the sublist boundaries one element to the right.
67-
68-
__Properties__
69-
* Worst case performance O(n^2)
70-
* Best case performance O(n^2)
71-
* Average case performance O(n^2)
72-
73-
###### View the algorithm in [action][selection-toptal]
74-
75-
### Shell
76-
![alt text][shell-image]
77-
78-
From [Wikipedia][shell-wiki]: Shellsort is a generalization of insertion sort that allows the exchange of items that are far apart. The idea is to arrange the list of elements so that, starting anywhere, considering every nth element gives a sorted list. Such a list is said to be h-sorted. Equivalently, it can be thought of as h interleaved lists, each individually sorted.
79-
80-
__Properties__
81-
* Worst case performance O(nlog2 2n)
82-
* Best case performance O(n log n)
83-
* Average case performance depends on gap sequence
84-
85-
###### View the algorithm in [action][shell-toptal]
86-
87-
### Time-Compexity Graphs
88-
89-
Comparing the complexity of sorting algorithms (Bubble Sort, Insertion Sort, Selection Sort)
90-
91-
[Complexity Graphs](https://github.com/prateekiiest/Python/blob/master/sorts/sortinggraphs.png)
92-
93-
----------------------------------------------------------------------------------
94-
95-
## Search Algorithms
96-
97-
### Linear
98-
![alt text][linear-image]
99-
100-
From [Wikipedia][linear-wiki]: linear search or sequential search is a method for finding a target value within a list. It sequentially checks each element of the list for the target value until a match is found or until all the elements have been searched.
101-
The linear search runs in at the worst linear time and makes at most n comparisons, where n is the length of the list.
102-
103-
__Properties__
104-
* Worst case performance O(n)
105-
* Best case performance O(1)
106-
* Average case performance O(n)
107-
* Worst case space complexity O(1) iterative
108-
109-
### Binary
110-
![alt text][binary-image]
111-
112-
From [Wikipedia][binary-wiki]: Binary search, also known as half-interval search or logarithmic search, is a search algorithm that finds the position of a target value within a sorted array. It compares the target value to the middle element of the array; if they are unequal, the half in which the target cannot lie is eliminated and the search continues on the remaining half until it is successful.
113-
114-
__Properties__
115-
* Worst case performance O(log n)
116-
* Best case performance O(1)
117-
* Average case performance O(log n)
118-
* Worst case space complexity O(1)
119-
120-
From [Wikipedia][shell-wiki]: Shellsort is a generalization of insertion sort that allows the exchange of items that are far apart. The idea is to arrange the list of elements so that, starting anywhere, considering every nth element gives a sorted list. Such a list is said to be h-sorted. Equivalently, it can be thought of as h interleaved lists, each individually sorted.
121-
122-
__Properties__
123-
* Worst case performance O(nlog2 2n)
124-
* Best case performance O(n log n)
125-
* Average case performance depends on gap sequence
126-
127-
###### View the algorithm in [action][shell-toptal]
128-
129-
[bubble-toptal]: https://www.toptal.com/developers/sorting-algorithms/bubble-sort
130-
[bubble-wiki]: https://en.wikipedia.org/wiki/Bubble_sort
131-
[bubble-image]: https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Bubblesort-edited-color.svg/220px-Bubblesort-edited-color.svg.png "Bubble Sort"
132-
133-
[insertion-toptal]: https://www.toptal.com/developers/sorting-algorithms/insertion-sort
134-
[insertion-wiki]: https://en.wikipedia.org/wiki/Insertion_sort
135-
[insertion-image]: https://upload.wikimedia.org/wikipedia/commons/7/7e/Insertionsort-edited.png "Insertion Sort"
136-
137-
[quick-toptal]: https://www.toptal.com/developers/sorting-algorithms/quick-sort
138-
[quick-wiki]: https://en.wikipedia.org/wiki/Quicksort
139-
[quick-image]: https://upload.wikimedia.org/wikipedia/commons/6/6a/Sorting_quicksort_anim.gif "Quick Sort"
140-
141-
[merge-toptal]: https://www.toptal.com/developers/sorting-algorithms/merge-sort
142-
[merge-wiki]: https://en.wikipedia.org/wiki/Merge_sort
143-
[merge-image]: https://upload.wikimedia.org/wikipedia/commons/c/cc/Merge-sort-example-300px.gif "Merge Sort"
144-
145-
[selection-toptal]: https://www.toptal.com/developers/sorting-algorithms/selection-sort
146-
[selection-wiki]: https://en.wikipedia.org/wiki/Selection_sort
147-
[selection-image]: https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Selection_sort_animation.gif/250px-Selection_sort_animation.gif "Selection Sort Sort"
148-
149-
[shell-toptal]: https://www.toptal.com/developers/sorting-algorithms/shell-sort
150-
[shell-wiki]: https://en.wikipedia.org/wiki/Shellsort
151-
[shell-image]: https://upload.wikimedia.org/wikipedia/commons/d/d8/Sorting_shellsort_anim.gif "Shell Sort"
152-
153-
[linear-wiki]: https://en.wikipedia.org/wiki/Linear_search
154-
[linear-image]: http://www.tutorialspoint.com/data_structures_algorithms/images/linear_search.gif
155-
156-
[binary-wiki]: https://en.wikipedia.org/wiki/Binary_search_algorithm
157-
[binary-image]: https://upload.wikimedia.org/wikipedia/commons/f/f7/Binary_search_into_array.png
158-
159-
160-
--------------------------------------------------------------------
161-
## Links to the rest of the algorithms
162-
163-
Conversions | Dynamic Programming |Ciphers|Miscellaneous|
164-
----------- |----------------------------------------------------------------|-------|-------------|
165-
[Any Base to Any Base](Conversions/AnyBaseToAnyBase.java)| [Coin Change](Dynamic%20Programming/CoinChange.java)|[Caesar](ciphers/Caesar.java)|[Heap Sort](misc/heap_sort.java)|
166-
[Any Base to Decimal](Conversions/AnyBaseToDecimal.java)|[Egg Dropping](Dynamic%20Programming/EggDropping.java)|[Columnar Transposition Cipher](ciphers/ColumnarTranspositionCipher.java)|[Palindromic Prime Checker](misc/PalindromicPrime.java)|
167-
[Binary to Decimal](Conversions/BinaryToDecimal.java)|[Fibonacci](Dynamic%20Programming/Fibonacci.java)|[RSA](ciphers/RSA.java)|More soon...|
168-
[Binary to HexaDecimal](Conversions/BinaryToHexadecimal.java)|[Kadane Algorithm](Dynamic%20Programming/KadaneAlgorithm.java)|more coming soon...|
169-
[Binary to Octal](Conversions/BinaryToOctal.java)|[Knapsack](Dynamic%20Programming/Knapsack.java)|
170-
[Decimal To Any Base](Conversions/DecimalToAnyBase.java)|[Longest Common Subsequence](Dynamic%20Programming/LongestCommonSubsequence.java)|
171-
[Decimal To Binary](Conversions/DecimalToBinary.java)|[Longest Increasing Subsequence](Dynamic%20Programming/LongestIncreasingSubsequence.java)|
172-
[Decimal To Hexadecimal](Conversions/DecimalToHexaDecimal.java)|[Rod Cutting](Dynamic%20Programming/RodCutting.java)|
173-
and much more...| and more...|
174-
175-
### Data Structures
176-
Graphs|Heaps|Lists|Queues|
177-
------|-----|-----|------|
178-
[BFS](Data%20Structures/Graphs/BFS.java)|[Empty Heap Exception](Data%20Structures/Heaps/EmptyHeapException.java)|[Circle Linked List](Data%20Structures/Lists/CircleLinkedList.java)|[Generic Array List Queue](Data%20Structures/Queues/GenericArrayListQueue.java)|
179-
[DFS](Data%20Structures/Graphs/DFS.java)|[Heap](Data%20Structures/Heaps/Heap.java)|[Doubly Linked List](Data%20Structures/Lists/DoublyLinkedList.java)|[Queues](Data%20Structures/Queues/Queues.java)|
180-
[Graphs](Data%20Structures/Graphs/Graphs.java)|[Heap Element](Data%20Structures/Heaps/HeapElement.java)|[Singly Linked List](Data%20Structures/Lists/SinglyLinkedList.java)|
181-
[Kruskals Algorithm](Data%20Structures/Graphs/KruskalsAlgorithm.java)|[Max Heap](Data%Structures/Heaps/MaxHeap.java)|
182-
[Matrix Graphs](Data%20Structures/Graphs/MatrixGraphs.java)|[Min Heap](Data%20Structures/Heaps/MinHeap.java)|
183-
[PrimMST](Data%20Structures/Graphs/PrimMST.java)|
184-
185-
Stacks|Trees|
186-
------|-----|
187-
[Node Stack](Data%20Structures/Stacks/NodeStack.java)|[AVL Tree](Data%20Structures/Trees/AVLTree.java)|
188-
[Stack of Linked List](Data%20Structures/Stacks/StackOfLinkedList.java)|[Binary Tree](Data%20Structures/Trees/BinaryTree.java)|
189-
[Stacks](Data%20Structures/Stacks/Stacks.java)|And much more...|
190-
191-
* [Bags](Data%20Structures/Bags/Bag.java)
192-
* [Buffer](Data%20Structures/Buffers/CircularBuffer.java)
193-
* [HashMap](Data%20Structures/HashMap/HashMap.java)
194-
* [Matrix](Data%20Structures/Matrix/Matrix.java)
1+
# The Algorithms - Java (WORK IN PROGRESS)
2+
3+
## Goal
4+
Make it a working Java project with full fledged test cases for each algorithm and correct package structures. Once we have enough test coverage, we would merge it with master
5+
6+
## Contribution Guidelines
7+
- If you add an algorithm then you have to add a test along with it. In absence of a test the PR would not be approved
8+
- Follow the correct coding guidelines. Refer [DecimalToAnyBase.java](https://github.com/TheAlgorithms/Java/blob/Development/src/main/com/java/conversions/DecimalToAnyBase.java) for algorithm and [DecimalToAnyBaseTest.java](https://github.com/TheAlgorithms/Java/blob/Development/src/test/com/java/conversions/DecimalToAnyBaseTest.java) for the test coding standards.
9+
- Please do not add a signature inside the code. The commit history is sufficient enough to determine who has added the code to the repo.
10+
- Make sure the algorithm which is getting added comes under a certain domain of Algorithms. Please don't create a package with name such as Misc, Others etc.
11+
- While making a PR make sure you are commiting the Java files only and not any project specific files. If you feel that your IDE is generating some extra files then either don't add them to git or add the extensions to ```.gitignore```
12+
- Please don't add solutions to problems from online judge such as Hackerrank, Leetcode etc
13+
14+
## Steps to raise a PR
15+
- Fork to [Java Repo](https://github.com/TheAlgorithms/Java)
16+
- Open the forked repo on your local machine
17+
- Switch to ```Development``` branch by using the command ```git checkout Development```
18+
- Make the changes on your local machine
19+
- Push the changes to the forked repository
20+
- Raise a PR against the Development branch

0 commit comments

Comments
 (0)