mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-09 12:11:28 +08:00
16
.github/workflows/build.yml
vendored
Normal file
16
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
name: Build
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
- name: Set up JDK 12
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 12
|
||||||
|
- run: find . -type f -name "*.java" > sources.txt
|
||||||
|
- run: javac @sources.txt
|
26
.github/workflows/prettier.yml
vendored
26
.github/workflows/prettier.yml
vendored
@ -1,26 +0,0 @@
|
|||||||
name: Prettier
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
- Development
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
prettier:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
ref: ${{ github.head_ref }}
|
|
||||||
|
|
||||||
- name: Prettify code
|
|
||||||
uses: creyD/prettier_action@v3.0
|
|
||||||
with:
|
|
||||||
prettier_options: --write **/*.{java,md}
|
|
||||||
commit_message: 'feat: prettify code'
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
483
DIRECTORY.md
483
DIRECTORY.md
@ -1,275 +1,258 @@
|
|||||||
## ciphers
|
|
||||||
|
|
||||||
- [AES](https://github.com/TheAlgorithms/Java/blob/master/ciphers/AES.java)
|
## ciphers
|
||||||
- [AESEncryption](https://github.com/TheAlgorithms/Java/blob/master/ciphers/AESEncryption.java)
|
* [AES](https://github.com/TheAlgorithms/Java/blob/master/ciphers/AES.java)
|
||||||
- [Caesar](https://github.com/TheAlgorithms/Java/blob/master/ciphers/Caesar.java)
|
* [AESEncryption](https://github.com/TheAlgorithms/Java/blob/master/ciphers/AESEncryption.java)
|
||||||
- [ColumnarTranspositionCipher](https://github.com/TheAlgorithms/Java/blob/master/ciphers/ColumnarTranspositionCipher.java)
|
* [Caesar](https://github.com/TheAlgorithms/Java/blob/master/ciphers/Caesar.java)
|
||||||
- [RSA](https://github.com/TheAlgorithms/Java/blob/master/ciphers/RSA.java)
|
* [ColumnarTranspositionCipher](https://github.com/TheAlgorithms/Java/blob/master/ciphers/ColumnarTranspositionCipher.java)
|
||||||
- [SimpleSubstitutionCipher](https://github.com/TheAlgorithms/Java/blob/master/ciphers/SimpleSubstitutionCipher.java)
|
* [RSA](https://github.com/TheAlgorithms/Java/blob/master/ciphers/RSA.java)
|
||||||
- [Vigenere](https://github.com/TheAlgorithms/Java/blob/master/ciphers/Vigenere.java)
|
* [SimpleSubstitutionCipher](https://github.com/TheAlgorithms/Java/blob/master/ciphers/SimpleSubstitutionCipher.java)
|
||||||
|
* [Vigenere](https://github.com/TheAlgorithms/Java/blob/master/ciphers/Vigenere.java)
|
||||||
|
|
||||||
## Conversions
|
## Conversions
|
||||||
|
* [AnyBaseToAnyBase](https://github.com/TheAlgorithms/Java/blob/master/Conversions/AnyBaseToAnyBase.java)
|
||||||
- [AnyBaseToAnyBase](https://github.com/TheAlgorithms/Java/blob/master/Conversions/AnyBaseToAnyBase.java)
|
* [AnyBaseToDecimal](https://github.com/TheAlgorithms/Java/blob/master/Conversions/AnyBaseToDecimal.java)
|
||||||
- [AnyBaseToDecimal](https://github.com/TheAlgorithms/Java/blob/master/Conversions/AnyBaseToDecimal.java)
|
* [AnytoAny](https://github.com/TheAlgorithms/Java/blob/master/Conversions/AnytoAny.java)
|
||||||
- [AnytoAny](https://github.com/TheAlgorithms/Java/blob/master/Conversions/AnytoAny.java)
|
* [BinaryToDecimal](https://github.com/TheAlgorithms/Java/blob/master/Conversions/BinaryToDecimal.java)
|
||||||
- [BinaryToDecimal](https://github.com/TheAlgorithms/Java/blob/master/Conversions/BinaryToDecimal.java)
|
* [BinaryToHexadecimal](https://github.com/TheAlgorithms/Java/blob/master/Conversions/BinaryToHexadecimal.java)
|
||||||
- [BinaryToHexadecimal](https://github.com/TheAlgorithms/Java/blob/master/Conversions/BinaryToHexadecimal.java)
|
* [BinaryToOctal](https://github.com/TheAlgorithms/Java/blob/master/Conversions/BinaryToOctal.java)
|
||||||
- [BinaryToOctal](https://github.com/TheAlgorithms/Java/blob/master/Conversions/BinaryToOctal.java)
|
* [DecimalToAnyBase](https://github.com/TheAlgorithms/Java/blob/master/Conversions/DecimalToAnyBase.java)
|
||||||
- [DecimalToAnyBase](https://github.com/TheAlgorithms/Java/blob/master/Conversions/DecimalToAnyBase.java)
|
* [DecimalToBinary](https://github.com/TheAlgorithms/Java/blob/master/Conversions/DecimalToBinary.java)
|
||||||
- [DecimalToBinary](https://github.com/TheAlgorithms/Java/blob/master/Conversions/DecimalToBinary.java)
|
* [DecimalToHexaDecimal](https://github.com/TheAlgorithms/Java/blob/master/Conversions/DecimalToHexaDecimal.java)
|
||||||
- [DecimalToHexaDecimal](https://github.com/TheAlgorithms/Java/blob/master/Conversions/DecimalToHexaDecimal.java)
|
* [DecimalToOctal](https://github.com/TheAlgorithms/Java/blob/master/Conversions/DecimalToOctal.java)
|
||||||
- [DecimalToOctal](https://github.com/TheAlgorithms/Java/blob/master/Conversions/DecimalToOctal.java)
|
* [HexaDecimalToBinary](https://github.com/TheAlgorithms/Java/blob/master/Conversions/HexaDecimalToBinary.java)
|
||||||
- [HexaDecimalToBinary](https://github.com/TheAlgorithms/Java/blob/master/Conversions/HexaDecimalToBinary.java)
|
* [HexaDecimalToDecimal](https://github.com/TheAlgorithms/Java/blob/master/Conversions/HexaDecimalToDecimal.java)
|
||||||
- [HexaDecimalToDecimal](https://github.com/TheAlgorithms/Java/blob/master/Conversions/HexaDecimalToDecimal.java)
|
* [HexToOct](https://github.com/TheAlgorithms/Java/blob/master/Conversions/HexToOct.java)
|
||||||
- [HexToOct](https://github.com/TheAlgorithms/Java/blob/master/Conversions/HexToOct.java)
|
* [IntegerToRoman](https://github.com/TheAlgorithms/Java/blob/master/Conversions/IntegerToRoman.java)
|
||||||
- [IntegerToRoman](https://github.com/TheAlgorithms/Java/blob/master/Conversions/IntegerToRoman.java)
|
* [OctalToDecimal](https://github.com/TheAlgorithms/Java/blob/master/Conversions/OctalToDecimal.java)
|
||||||
- [OctalToDecimal](https://github.com/TheAlgorithms/Java/blob/master/Conversions/OctalToDecimal.java)
|
* [OctalToHexadecimal](https://github.com/TheAlgorithms/Java/blob/master/Conversions/OctalToHexadecimal.java)
|
||||||
- [OctalToHexadecimal](https://github.com/TheAlgorithms/Java/blob/master/Conversions/OctalToHexadecimal.java)
|
* [RomanToInteger](https://github.com/TheAlgorithms/Java/blob/master/Conversions/RomanToInteger.java)
|
||||||
- [RomanToInteger](https://github.com/TheAlgorithms/Java/blob/master/Conversions/RomanToInteger.java)
|
|
||||||
|
|
||||||
## DataStructures
|
## DataStructures
|
||||||
|
* Bags
|
||||||
- Bags
|
* [Bag](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Bags/Bag.java)
|
||||||
- [Bag](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Bags/Bag.java)
|
* Buffers
|
||||||
- Buffers
|
* [CircularBuffer](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Buffers/CircularBuffer.java)
|
||||||
- [CircularBuffer](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Buffers/CircularBuffer.java)
|
* DynamicArray
|
||||||
- DynamicArray
|
* [DynamicArray](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/DynamicArray/DynamicArray.java)
|
||||||
- [DynamicArray](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/DynamicArray/DynamicArray.java)
|
* Graphs
|
||||||
- Graphs
|
* [A Star](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/A_Star.java)
|
||||||
- [A Star](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/A_Star.java)
|
* [BellmanFord](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/BellmanFord.java)
|
||||||
- [BellmanFord](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/BellmanFord.java)
|
* [ConnectedComponent](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/ConnectedComponent.java)
|
||||||
- [ConnectedComponent](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/ConnectedComponent.java)
|
* [Cycles](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/Cycles.java)
|
||||||
- [Cycles](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/Cycles.java)
|
* [FloydWarshall](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/FloydWarshall.java)
|
||||||
- [FloydWarshall](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/FloydWarshall.java)
|
* [Graphs](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/Graphs.java)
|
||||||
- [GraphAlgos](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/GraphAlgos.java)
|
* [Kruskal](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/Kruskal.java)
|
||||||
- [Graphs](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/Graphs.java)
|
* [MatrixGraphs](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/MatrixGraphs.java)
|
||||||
- [Kruskal](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/Kruskal.java)
|
* [PrimMST](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/PrimMST.java)
|
||||||
- [MatrixGraphs](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/MatrixGraphs.java)
|
* HashMap
|
||||||
- [PrimMST](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Graphs/PrimMST.java)
|
* Hashing
|
||||||
- HashMap
|
* [HashMap](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/HashMap/Hashing/HashMap.java)
|
||||||
- Hashing
|
* [HashMapLinearProbing](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/HashMap/Hashing/HashMapLinearProbing.java)
|
||||||
- [HashMap](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/HashMap/Hashing/HashMap.java)
|
* [Main](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/HashMap/Hashing/Main.java)
|
||||||
- [HashMapLinearProbing](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/HashMap/Hashing/HashMapLinearProbing.java)
|
* [MainLinearProbing](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/HashMap/Hashing/MainLinearProbing.java)
|
||||||
- [Main](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/HashMap/Hashing/Main.java)
|
* Heaps
|
||||||
- [MainLinearProbing](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/HashMap/Hashing/MainLinearProbing.java)
|
* [EmptyHeapException](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Heaps/EmptyHeapException.java)
|
||||||
- Heaps
|
* [Heap](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Heaps/Heap.java)
|
||||||
- [EmptyHeapException](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Heaps/EmptyHeapException.java)
|
* [HeapElement](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Heaps/HeapElement.java)
|
||||||
- [Heap](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Heaps/Heap.java)
|
* [MaxHeap](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Heaps/MaxHeap.java)
|
||||||
- [HeapElement](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Heaps/HeapElement.java)
|
* [MinHeap](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Heaps/MinHeap.java)
|
||||||
- [MaxHeap](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Heaps/MaxHeap.java)
|
* [MinPriorityQueue](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Heaps/MinPriorityQueue.java)
|
||||||
- [MinHeap](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Heaps/MinHeap.java)
|
* Lists
|
||||||
- [MinPriorityQueue](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Heaps/MinPriorityQueue.java)
|
* [CircleLinkedList](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/CircleLinkedList.java)
|
||||||
- Lists
|
* [CountSinglyLinkedListRecursion](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/CountSinglyLinkedListRecursion.java)
|
||||||
- [CircleLinkedList](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/CircleLinkedList.java)
|
* [CursorLinkedList](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/CursorLinkedList.java)
|
||||||
- [CountSinglyLinkedListRecursion](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/CountSinglyLinkedListRecursion.java)
|
* [DoublyLinkedList](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/DoublyLinkedList.java)
|
||||||
- [CursorLinkedList](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/CursorLinkedList.java)
|
* [Merge K SortedLinkedlist](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/Merge_K_SortedLinkedlist.java)
|
||||||
- [DoublyLinkedList](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/DoublyLinkedList.java)
|
* [MergeSortedArrayList](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/MergeSortedArrayList.java)
|
||||||
- [ListAddnFun](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/ListAddnFun.java)
|
* [MergeSortedSinglyLinkedList](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/MergeSortedSinglyLinkedList.java)
|
||||||
- [Merge K SortedLinkedlist](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/Merge_K_SortedLinkedlist.java)
|
* [SearchSinglyLinkedListRecursion](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/SearchSinglyLinkedListRecursion.java)
|
||||||
- [MergeSortedArrayList](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/MergeSortedArrayList.java)
|
* [SinglyLinkedList](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/SinglyLinkedList.java)
|
||||||
- [MergeSortedSinglyLinkedList](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/MergeSortedSinglyLinkedList.java)
|
* Queues
|
||||||
- [SearchSinglyLinkedListRecursion](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/SearchSinglyLinkedListRecursion.java)
|
* [GenericArrayListQueue](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Queues/GenericArrayListQueue.java)
|
||||||
- [SinglyLinkedList](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Lists/SinglyLinkedList.java)
|
* [LinkedQueue](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Queues/LinkedQueue.java)
|
||||||
- Queues
|
* [PriorityQueues](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Queues/PriorityQueues.java)
|
||||||
- [GenericArrayListQueue](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Queues/GenericArrayListQueue.java)
|
* [Queues](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Queues/Queues.java)
|
||||||
- [LinkedQueue](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Queues/LinkedQueue.java)
|
* Stacks
|
||||||
- [PriorityQueues](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Queues/PriorityQueues.java)
|
* [BalancedBrackets](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Stacks/BalancedBrackets.java)
|
||||||
- [Queues](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Queues/Queues.java)
|
* [DecimalToAnyUsingStack](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Stacks/DecimalToAnyUsingStack.java)
|
||||||
- Stacks
|
* [NodeStack](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Stacks/NodeStack.java)
|
||||||
- [BalancedBrackets](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Stacks/BalancedBrackets.java)
|
* [StackArray](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Stacks/StackArray.java)
|
||||||
- [DecimalToAnyUsingStack](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Stacks/DecimalToAnyUsingStack.java)
|
* [StackArrayList](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Stacks/StackArrayList.java)
|
||||||
- [NodeStack](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Stacks/NodeStack.java)
|
* [StackOfLinkedList](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Stacks/StackOfLinkedList.java)
|
||||||
- [StackArray](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Stacks/StackArray.java)
|
* Trees
|
||||||
- [StackArrayList](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Stacks/StackArrayList.java)
|
* [AVLTree](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/AVLTree.java)
|
||||||
- [StackOfLinkedList](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Stacks/StackOfLinkedList.java)
|
* [BinaryTree](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/BinaryTree.java)
|
||||||
- Trees
|
* [BSTIterative](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/BSTIterative.java)
|
||||||
- [AVLTree](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/AVLTree.java)
|
* [BSTRecursive](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/BSTRecursive.java)
|
||||||
- [BinaryTree](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/BinaryTree.java)
|
* [GenericTree](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/GenericTree.java)
|
||||||
- [BSTIterative](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/BSTIterative.java)
|
* [LevelOrderTraversal](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/LevelOrderTraversal.java)
|
||||||
- [BSTRecursive](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/BSTRecursive.java)
|
* [LevelOrderTraversalQueue](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/LevelOrderTraversalQueue.java)
|
||||||
- [GenericTree](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/GenericTree.java)
|
* [PrintTopViewofTree](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/PrintTopViewofTree.java)
|
||||||
- [LevelOrderTraversal](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/LevelOrderTraversal.java)
|
* [RedBlackBST](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/RedBlackBST.java)
|
||||||
- [LevelOrderTraversalQueue](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/LevelOrderTraversalQueue.java)
|
* [TreeTraversal](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/TreeTraversal.java)
|
||||||
- [PrintTopViewofTree](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/PrintTopViewofTree.java)
|
* [TrieImp](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/TrieImp.java)
|
||||||
- [RedBlackBST](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/RedBlackBST.java)
|
* [ValidBSTOrNot](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/ValidBSTOrNot.java)
|
||||||
- [TreeTraversal](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/TreeTraversal.java)
|
|
||||||
- [TrieImp](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/TrieImp.java)
|
|
||||||
- [ValidBSTOrNot](https://github.com/TheAlgorithms/Java/blob/master/DataStructures/Trees/ValidBSTOrNot.java)
|
|
||||||
|
|
||||||
## divideconquer
|
## divideconquer
|
||||||
|
* [ClosestPair](https://github.com/TheAlgorithms/Java/blob/master/divideconquer/ClosestPair.java)
|
||||||
- [ClosestPair](https://github.com/TheAlgorithms/Java/blob/master/divideconquer/ClosestPair.java)
|
* [SkylineAlgorithm](https://github.com/TheAlgorithms/Java/blob/master/divideconquer/SkylineAlgorithm.java)
|
||||||
- [SkylineAlgorithm](https://github.com/TheAlgorithms/Java/blob/master/divideconquer/SkylineAlgorithm.java)
|
|
||||||
|
|
||||||
## DynamicProgramming
|
## DynamicProgramming
|
||||||
|
* [BoardPath](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/BoardPath.java)
|
||||||
- [BoardPath](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/BoardPath.java)
|
* [CoinChange](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/CoinChange.java)
|
||||||
- [CoinChange](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/CoinChange.java)
|
* [EditDistance](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/EditDistance.java)
|
||||||
- [EditDistance](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/EditDistance.java)
|
* [EggDropping](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/EggDropping.java)
|
||||||
- [EggDropping](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/EggDropping.java)
|
* [Fibonacci](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/Fibonacci.java)
|
||||||
- [Fibonacci](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/Fibonacci.java)
|
* [FordFulkerson](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/FordFulkerson.java)
|
||||||
- [FordFulkerson](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/FordFulkerson.java)
|
* [KadaneAlgorithm](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/KadaneAlgorithm.java)
|
||||||
- [KadaneAlgorithm](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/KadaneAlgorithm.java)
|
* [Knapsack](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/Knapsack.java)
|
||||||
- [Knapsack](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/Knapsack.java)
|
* [LevenshteinDistance](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/LevenshteinDistance.java)
|
||||||
- [LevenshteinDistance](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/LevenshteinDistance.java)
|
* [LongestCommonSubsequence](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/LongestCommonSubsequence.java)
|
||||||
- [LongestCommonSubsequence](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/LongestCommonSubsequence.java)
|
* [LongestIncreasingSubsequence](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/LongestIncreasingSubsequence.java)
|
||||||
- [LongestIncreasingSubsequence](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/LongestIncreasingSubsequence.java)
|
* [LongestPalindromicSubsequence](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/LongestPalindromicSubsequence.java)
|
||||||
- [LongestPalindromicSubsequence](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/LongestPalindromicSubsequence.java)
|
* [LongestValidParentheses](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/LongestValidParentheses.java)
|
||||||
- [LongestPalindromicSubsequenceTests](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/LongestPalindromicSubsequenceTests.java)
|
* [MatrixChainMultiplication](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/MatrixChainMultiplication.java)
|
||||||
- [LongestValidParentheses](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/LongestValidParentheses.java)
|
* [MinimumSumPartition](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/MinimumSumPartition.java)
|
||||||
- [MatrixChainMultiplication](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/MatrixChainMultiplication.java)
|
* [RodCutting](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/RodCutting.java)
|
||||||
- [MinimumSumPartition](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/MinimumSumPartition.java)
|
* [SubsetSum](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/SubsetSum.java)
|
||||||
- [RodCutting](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/RodCutting.java)
|
|
||||||
- [SubsetSum](https://github.com/TheAlgorithms/Java/blob/master/DynamicProgramming/SubsetSum.java)
|
|
||||||
|
|
||||||
## Maths
|
## Maths
|
||||||
|
* [AbsoluteMax](https://github.com/TheAlgorithms/Java/blob/master/Maths/AbsoluteMax.java)
|
||||||
- [AbsoluteMax](https://github.com/TheAlgorithms/Java/blob/master/Maths/AbsoluteMax.java)
|
* [AbsoluteMin](https://github.com/TheAlgorithms/Java/blob/master/Maths/AbsoluteMin.java)
|
||||||
- [AbsoluteMin](https://github.com/TheAlgorithms/Java/blob/master/Maths/AbsoluteMin.java)
|
* [AbsoluteValue](https://github.com/TheAlgorithms/Java/blob/master/Maths/AbsoluteValue.java)
|
||||||
- [AbsoluteValue](https://github.com/TheAlgorithms/Java/blob/master/Maths/AbsoluteValue.java)
|
* [AliquotSum](https://github.com/TheAlgorithms/Java/blob/master/Maths/AliquotSum.java)
|
||||||
- [AliquotSum](https://github.com/TheAlgorithms/Java/blob/master/Maths/AliquotSum.java)
|
* [AmicableNumber](https://github.com/TheAlgorithms/Java/blob/master/Maths/AmicableNumber.java)
|
||||||
- [AmicableNumber](https://github.com/TheAlgorithms/Java/blob/master/Maths/AmicableNumber.java)
|
* [Area](https://github.com/TheAlgorithms/Java/blob/master/Maths/Area.java)
|
||||||
- [Area](https://github.com/TheAlgorithms/Java/blob/master/Maths/Area.java)
|
* [Armstrong](https://github.com/TheAlgorithms/Java/blob/master/Maths/Armstrong.java)
|
||||||
- [Armstrong](https://github.com/TheAlgorithms/Java/blob/master/Maths/Armstrong.java)
|
* [Average](https://github.com/TheAlgorithms/Java/blob/master/Maths/Average.java)
|
||||||
- [Average](https://github.com/TheAlgorithms/Java/blob/master/Maths/Average.java)
|
* [Ceil](https://github.com/TheAlgorithms/Java/blob/master/Maths/Ceil.java)
|
||||||
- [Ceil](https://github.com/TheAlgorithms/Java/blob/master/Maths/Ceil.java)
|
* [Combinations](https://github.com/TheAlgorithms/Java/blob/master/Maths/Combinations.java)
|
||||||
- [Combinations](https://github.com/TheAlgorithms/Java/blob/master/Maths/Combinations.java)
|
* [Factorial](https://github.com/TheAlgorithms/Java/blob/master/Maths/Factorial.java)
|
||||||
- [Factorial](https://github.com/TheAlgorithms/Java/blob/master/Maths/Factorial.java)
|
* [FactorialRecursion](https://github.com/TheAlgorithms/Java/blob/master/Maths/FactorialRecursion.java)
|
||||||
- [FactorialRecursion](https://github.com/TheAlgorithms/Java/blob/master/Maths/FactorialRecursion.java)
|
* [FibonacciNumber](https://github.com/TheAlgorithms/Java/blob/master/Maths/FibonacciNumber.java)
|
||||||
- [FibonacciNumber](https://github.com/TheAlgorithms/Java/blob/master/Maths/FibonacciNumber.java)
|
* [FindMax](https://github.com/TheAlgorithms/Java/blob/master/Maths/FindMax.java)
|
||||||
- [FindMax](https://github.com/TheAlgorithms/Java/blob/master/Maths/FindMax.java)
|
* [FindMaxRecursion](https://github.com/TheAlgorithms/Java/blob/master/Maths/FindMaxRecursion.java)
|
||||||
- [FindMaxRecursion](https://github.com/TheAlgorithms/Java/blob/master/Maths/FindMaxRecursion.java)
|
* [FindMin](https://github.com/TheAlgorithms/Java/blob/master/Maths/FindMin.java)
|
||||||
- [FindMin](https://github.com/TheAlgorithms/Java/blob/master/Maths/FindMin.java)
|
* [FindMinRecursion](https://github.com/TheAlgorithms/Java/blob/master/Maths/FindMinRecursion.java)
|
||||||
- [FindMinRecursion](https://github.com/TheAlgorithms/Java/blob/master/Maths/FindMinRecursion.java)
|
* [Floor](https://github.com/TheAlgorithms/Java/blob/master/Maths/Floor.java)
|
||||||
- [Floor](https://github.com/TheAlgorithms/Java/blob/master/Maths/Floor.java)
|
* [GCD](https://github.com/TheAlgorithms/Java/blob/master/Maths/GCD.java)
|
||||||
- [GCD](https://github.com/TheAlgorithms/Java/blob/master/Maths/GCD.java)
|
* [GCDRecursion](https://github.com/TheAlgorithms/Java/blob/master/Maths/GCDRecursion.java)
|
||||||
- [GCDRecursion](https://github.com/TheAlgorithms/Java/blob/master/Maths/GCDRecursion.java)
|
* [LucasSeries](https://github.com/TheAlgorithms/Java/blob/master/Maths/LucasSeries.java)
|
||||||
- [LucasSeries](https://github.com/TheAlgorithms/Java/blob/master/Maths/LucasSeries.java)
|
* [MaxValue](https://github.com/TheAlgorithms/Java/blob/master/Maths/MaxValue.java)
|
||||||
- [MaxValue](https://github.com/TheAlgorithms/Java/blob/master/Maths/MaxValue.java)
|
* [Median](https://github.com/TheAlgorithms/Java/blob/master/Maths/Median.java)
|
||||||
- [Median](https://github.com/TheAlgorithms/Java/blob/master/Maths/Median.java)
|
* [MinValue](https://github.com/TheAlgorithms/Java/blob/master/Maths/MinValue.java)
|
||||||
- [MinValue](https://github.com/TheAlgorithms/Java/blob/master/Maths/MinValue.java)
|
* [Mode](https://github.com/TheAlgorithms/Java/blob/master/Maths/Mode.java)
|
||||||
- [Mode](https://github.com/TheAlgorithms/Java/blob/master/Maths/Mode.java)
|
* [NumberOfDigits](https://github.com/TheAlgorithms/Java/blob/master/Maths/NumberOfDigits.java)
|
||||||
- [NumberOfDigits](https://github.com/TheAlgorithms/Java/blob/master/Maths/NumberOfDigits.java)
|
* [PalindromeNumber](https://github.com/TheAlgorithms/Java/blob/master/Maths/PalindromeNumber.java)
|
||||||
- [PalindromeNumber](https://github.com/TheAlgorithms/Java/blob/master/Maths/PalindromeNumber.java)
|
* [ParseInteger](https://github.com/TheAlgorithms/Java/blob/master/Maths/ParseInteger.java)
|
||||||
- [ParseInteger](https://github.com/TheAlgorithms/Java/blob/master/Maths/ParseInteger.java)
|
* [PerfectCube](https://github.com/TheAlgorithms/Java/blob/master/Maths/PerfectCube.java)
|
||||||
- [PerfectCube](https://github.com/TheAlgorithms/Java/blob/master/Maths/PerfectCube.java)
|
* [PerfectNumber](https://github.com/TheAlgorithms/Java/blob/master/Maths/PerfectNumber.java)
|
||||||
- [PerfectNumber](https://github.com/TheAlgorithms/Java/blob/master/Maths/PerfectNumber.java)
|
* [PerfectSquare](https://github.com/TheAlgorithms/Java/blob/master/Maths/PerfectSquare.java)
|
||||||
- [PerfectSquare](https://github.com/TheAlgorithms/Java/blob/master/Maths/PerfectSquare.java)
|
* [Pow](https://github.com/TheAlgorithms/Java/blob/master/Maths/Pow.java)
|
||||||
- [Pow](https://github.com/TheAlgorithms/Java/blob/master/Maths/Pow.java)
|
* [PowerOfTwoOrNot](https://github.com/TheAlgorithms/Java/blob/master/Maths/PowerOfTwoOrNot.java)
|
||||||
- [PowerOfTwoOrNot](https://github.com/TheAlgorithms/Java/blob/master/Maths/PowerOfTwoOrNot.java)
|
* [PowRecursion](https://github.com/TheAlgorithms/Java/blob/master/Maths/PowRecursion.java)
|
||||||
- [PowRecursion](https://github.com/TheAlgorithms/Java/blob/master/Maths/PowRecursion.java)
|
* [PrimeCheck](https://github.com/TheAlgorithms/Java/blob/master/Maths/PrimeCheck.java)
|
||||||
- [PrimeCheck](https://github.com/TheAlgorithms/Java/blob/master/Maths/PrimeCheck.java)
|
* [PrimeFactorization](https://github.com/TheAlgorithms/Java/blob/master/Maths/PrimeFactorization.java)
|
||||||
- [PrimeFactorization](https://github.com/TheAlgorithms/Java/blob/master/Maths/PrimeFactorization.java)
|
* [PythagoreanTriple](https://github.com/TheAlgorithms/Java/blob/master/Maths/PythagoreanTriple.java)
|
||||||
- [PythagoreanTriple](https://github.com/TheAlgorithms/Java/blob/master/Maths/PythagoreanTriple.java)
|
* [SumOfArithmeticSeries](https://github.com/TheAlgorithms/Java/blob/master/Maths/SumOfArithmeticSeries.java)
|
||||||
- [SumOfArithmeticSeries](https://github.com/TheAlgorithms/Java/blob/master/Maths/SumOfArithmeticSeries.java)
|
* [SumOfDigits](https://github.com/TheAlgorithms/Java/blob/master/Maths/SumOfDigits.java)
|
||||||
- [SumOfDigits](https://github.com/TheAlgorithms/Java/blob/master/Maths/SumOfDigits.java)
|
* [VampireNumber](https://github.com/TheAlgorithms/Java/blob/master/Maths/VampireNumber.java)
|
||||||
- [VampireNumber](https://github.com/TheAlgorithms/Java/blob/master/Maths/VampireNumber.java)
|
|
||||||
|
|
||||||
## MinimizingLateness
|
## MinimizingLateness
|
||||||
|
* [MinimizingLateness](https://github.com/TheAlgorithms/Java/blob/master/MinimizingLateness/MinimizingLateness.java)
|
||||||
- [MinimizingLateness](https://github.com/TheAlgorithms/Java/blob/master/MinimizingLateness/MinimizingLateness.java)
|
|
||||||
|
|
||||||
## Misc
|
## Misc
|
||||||
|
* [MedianOfRunningArray](https://github.com/TheAlgorithms/Java/blob/master/Misc/MedianOfRunningArray.java)
|
||||||
- [HeapSort](https://github.com/TheAlgorithms/Java/blob/master/Misc/HeapSort.java)
|
* [PalindromePrime](https://github.com/TheAlgorithms/Java/blob/master/Misc/PalindromePrime.java)
|
||||||
- [MedianOfRunningArray](https://github.com/TheAlgorithms/Java/blob/master/Misc/MedianOfRunningArray.java)
|
|
||||||
- [PalindromePrime](https://github.com/TheAlgorithms/Java/blob/master/Misc/PalindromePrime.java)
|
|
||||||
|
|
||||||
## Others
|
## Others
|
||||||
|
* [BestFit](https://github.com/TheAlgorithms/Java/blob/master/Others/BestFit.java)
|
||||||
- [3 sum](https://github.com/TheAlgorithms/Java/blob/master/Others/3%20sum.java)
|
* [BrianKernighanAlgorithm](https://github.com/TheAlgorithms/Java/blob/master/Others/BrianKernighanAlgorithm.java)
|
||||||
- [BestFit](https://github.com/TheAlgorithms/Java/blob/master/Others/BestFit.java)
|
* [CountChar](https://github.com/TheAlgorithms/Java/blob/master/Others/CountChar.java)
|
||||||
- [BrianKernighanAlgorithm](https://github.com/TheAlgorithms/Java/blob/master/Others/BrianKernighanAlgorithm.java)
|
* [CountWords](https://github.com/TheAlgorithms/Java/blob/master/Others/CountWords.java)
|
||||||
- [CountChar](https://github.com/TheAlgorithms/Java/blob/master/Others/CountChar.java)
|
* [CRC32](https://github.com/TheAlgorithms/Java/blob/master/Others/CRC32.java)
|
||||||
- [CountWords](https://github.com/TheAlgorithms/Java/blob/master/Others/CountWords.java)
|
* [CRCAlgorithm](https://github.com/TheAlgorithms/Java/blob/master/Others/CRCAlgorithm.java)
|
||||||
- [CRC32](https://github.com/TheAlgorithms/Java/blob/master/Others/CRC32.java)
|
* [Dijkstra](https://github.com/TheAlgorithms/Java/blob/master/Others/Dijkstra.java)
|
||||||
- [CRCAlgorithm](https://github.com/TheAlgorithms/Java/blob/master/Others/CRCAlgorithm.java)
|
* [EulersFunction](https://github.com/TheAlgorithms/Java/blob/master/Others/EulersFunction.java)
|
||||||
- [Dijkstra](https://github.com/TheAlgorithms/Java/blob/master/Others/Dijkstra.java)
|
* [FibToN](https://github.com/TheAlgorithms/Java/blob/master/Others/FibToN.java)
|
||||||
- [EulersFunction](https://github.com/TheAlgorithms/Java/blob/master/Others/EulersFunction.java)
|
* [FirstFit](https://github.com/TheAlgorithms/Java/blob/master/Others/FirstFit.java)
|
||||||
- [FibToN](https://github.com/TheAlgorithms/Java/blob/master/Others/FibToN.java)
|
* [FloydTriangle](https://github.com/TheAlgorithms/Java/blob/master/Others/FloydTriangle.java)
|
||||||
- [FirstFit](https://github.com/TheAlgorithms/Java/blob/master/Others/FirstFit.java)
|
* [GuassLegendre](https://github.com/TheAlgorithms/Java/blob/master/Others/GuassLegendre.java)
|
||||||
- [FloydTriangle](https://github.com/TheAlgorithms/Java/blob/master/Others/FloydTriangle.java)
|
* [InsertDeleteInArray](https://github.com/TheAlgorithms/Java/blob/master/Others/InsertDeleteInArray.java)
|
||||||
- [GuassLegendre](https://github.com/TheAlgorithms/Java/blob/master/Others/GuassLegendre.java)
|
* [KMP](https://github.com/TheAlgorithms/Java/blob/master/Others/KMP.java)
|
||||||
- [InsertDeleteInArray](https://github.com/TheAlgorithms/Java/blob/master/Others/InsertDeleteInArray.java)
|
* [Krishnamurthy](https://github.com/TheAlgorithms/Java/blob/master/Others/Krishnamurthy.java)
|
||||||
- [KMP](https://github.com/TheAlgorithms/Java/blob/master/Others/KMP.java)
|
* [LinearCongruentialGenerator](https://github.com/TheAlgorithms/Java/blob/master/Others/LinearCongruentialGenerator.java)
|
||||||
- [Krishnamurthy](https://github.com/TheAlgorithms/Java/blob/master/Others/Krishnamurthy.java)
|
* [LowestBasePalindrome](https://github.com/TheAlgorithms/Java/blob/master/Others/LowestBasePalindrome.java)
|
||||||
- [LinearCongruentialGenerator](https://github.com/TheAlgorithms/Java/blob/master/Others/LinearCongruentialGenerator.java)
|
* [PasswordGen](https://github.com/TheAlgorithms/Java/blob/master/Others/PasswordGen.java)
|
||||||
- [LowestBasePalindrome](https://github.com/TheAlgorithms/Java/blob/master/Others/LowestBasePalindrome.java)
|
* [PerlinNoise](https://github.com/TheAlgorithms/Java/blob/master/Others/PerlinNoise.java)
|
||||||
- [PasswordGen](https://github.com/TheAlgorithms/Java/blob/master/Others/PasswordGen.java)
|
* [QueueUsingTwoStacks](https://github.com/TheAlgorithms/Java/blob/master/Others/QueueUsingTwoStacks.java)
|
||||||
- [PerlinNoise](https://github.com/TheAlgorithms/Java/blob/master/Others/PerlinNoise.java)
|
* [RabinKarp](https://github.com/TheAlgorithms/Java/blob/master/Others/RabinKarp.java)
|
||||||
- [QueueUsingTwoStacks](https://github.com/TheAlgorithms/Java/blob/master/Others/QueueUsingTwoStacks.java)
|
* [RemoveDuplicateFromString](https://github.com/TheAlgorithms/Java/blob/master/Others/RemoveDuplicateFromString.java)
|
||||||
- [RabinKarp](https://github.com/TheAlgorithms/Java/blob/master/Others/RabinKarp.java)
|
* [ReturnSubsequence](https://github.com/TheAlgorithms/Java/blob/master/Others/ReturnSubsequence.java)
|
||||||
- [RemoveDuplicateFromString](https://github.com/TheAlgorithms/Java/blob/master/Others/RemoveDuplicateFromString.java)
|
* [ReverseStackUsingRecursion](https://github.com/TheAlgorithms/Java/blob/master/Others/ReverseStackUsingRecursion.java)
|
||||||
- [ReturnSubsequence](https://github.com/TheAlgorithms/Java/blob/master/Others/ReturnSubsequence.java)
|
* [RootPrecision](https://github.com/TheAlgorithms/Java/blob/master/Others/RootPrecision.java)
|
||||||
- [ReverseStackUsingRecursion](https://github.com/TheAlgorithms/Java/blob/master/Others/ReverseStackUsingRecursion.java)
|
* [SieveOfEratosthenes](https://github.com/TheAlgorithms/Java/blob/master/Others/SieveOfEratosthenes.java)
|
||||||
- [RootPrecision](https://github.com/TheAlgorithms/Java/blob/master/Others/RootPrecision.java)
|
* [SJF](https://github.com/TheAlgorithms/Java/blob/master/Others/SJF.java)
|
||||||
- [Rotation of array without using extra space](https://github.com/TheAlgorithms/Java/blob/master/Others/Rotation%20of%20array%20without%20using%20extra%20space.java)
|
* [SkylineProblem](https://github.com/TheAlgorithms/Java/blob/master/Others/SkylineProblem.java)
|
||||||
- [SieveOfEratosthenes](https://github.com/TheAlgorithms/Java/blob/master/Others/SieveOfEratosthenes.java)
|
* [StackPostfixNotation](https://github.com/TheAlgorithms/Java/blob/master/Others/StackPostfixNotation.java)
|
||||||
- [SJF](https://github.com/TheAlgorithms/Java/blob/master/Others/SJF.java)
|
* [StringMatchFiniteAutomata](https://github.com/TheAlgorithms/Java/blob/master/Others/StringMatchFiniteAutomata.java)
|
||||||
- [SkylineProblem](https://github.com/TheAlgorithms/Java/blob/master/Others/SkylineProblem.java)
|
* [ThreeSum](https://github.com/TheAlgorithms/Java/blob/master/Others/ThreeSum.java)
|
||||||
- [StackPostfixNotation](https://github.com/TheAlgorithms/Java/blob/master/Others/StackPostfixNotation.java)
|
* [TopKWords](https://github.com/TheAlgorithms/Java/blob/master/Others/TopKWords.java)
|
||||||
- [StringMatchFiniteAutomata](https://github.com/TheAlgorithms/Java/blob/master/Others/StringMatchFiniteAutomata.java)
|
* [TowerOfHanoi](https://github.com/TheAlgorithms/Java/blob/master/Others/TowerOfHanoi.java)
|
||||||
- [TopKWords](https://github.com/TheAlgorithms/Java/blob/master/Others/TopKWords.java)
|
* [TwoPointers](https://github.com/TheAlgorithms/Java/blob/master/Others/TwoPointers.java)
|
||||||
- [TowerOfHanoi](https://github.com/TheAlgorithms/Java/blob/master/Others/TowerOfHanoi.java)
|
* [WorstFit](https://github.com/TheAlgorithms/Java/blob/master/Others/WorstFit.java)
|
||||||
- [TwoPointers](https://github.com/TheAlgorithms/Java/blob/master/Others/TwoPointers.java)
|
|
||||||
- [WorstFit](https://github.com/TheAlgorithms/Java/blob/master/Others/WorstFit.java)
|
|
||||||
|
|
||||||
## ProjectEuler
|
## ProjectEuler
|
||||||
|
* [Problem01](https://github.com/TheAlgorithms/Java/blob/master/ProjectEuler/Problem01.java)
|
||||||
- [Problem01](https://github.com/TheAlgorithms/Java/blob/master/ProjectEuler/Problem01.java)
|
* [Problem02](https://github.com/TheAlgorithms/Java/blob/master/ProjectEuler/Problem02.java)
|
||||||
- [Problem02](https://github.com/TheAlgorithms/Java/blob/master/ProjectEuler/Problem02.java)
|
* [Problem04](https://github.com/TheAlgorithms/Java/blob/master/ProjectEuler/Problem04.java)
|
||||||
- [Problem04](https://github.com/TheAlgorithms/Java/blob/master/ProjectEuler/Problem04.java)
|
* [Problem06](https://github.com/TheAlgorithms/Java/blob/master/ProjectEuler/Problem06.java)
|
||||||
- [Problem06](https://github.com/TheAlgorithms/Java/blob/master/ProjectEuler/Problem06.java)
|
* [Problem07](https://github.com/TheAlgorithms/Java/blob/master/ProjectEuler/Problem07.java)
|
||||||
- [Problem07](https://github.com/TheAlgorithms/Java/blob/master/ProjectEuler/Problem07.java)
|
* [Problem09](https://github.com/TheAlgorithms/Java/blob/master/ProjectEuler/Problem09.java)
|
||||||
- [Problem09](https://github.com/TheAlgorithms/Java/blob/master/ProjectEuler/Problem09.java)
|
* [Problem10](https://github.com/TheAlgorithms/Java/blob/master/ProjectEuler/Problem10.java)
|
||||||
- [Problem10](https://github.com/TheAlgorithms/Java/blob/master/ProjectEuler/Problem10.java)
|
* [Problem12](https://github.com/TheAlgorithms/Java/blob/master/ProjectEuler/Problem12.java)
|
||||||
- [Problem12](https://github.com/TheAlgorithms/Java/blob/master/ProjectEuler/Problem12.java)
|
|
||||||
|
|
||||||
## Searches
|
## Searches
|
||||||
|
* [BinarySearch](https://github.com/TheAlgorithms/Java/blob/master/Searches/BinarySearch.java)
|
||||||
- [BinarySearch](https://github.com/TheAlgorithms/Java/blob/master/Searches/BinarySearch.java)
|
* [InterpolationSearch](https://github.com/TheAlgorithms/Java/blob/master/Searches/InterpolationSearch.java)
|
||||||
- [InterpolationSearch](https://github.com/TheAlgorithms/Java/blob/master/Searches/InterpolationSearch.java)
|
* [IterativeBinarySearch](https://github.com/TheAlgorithms/Java/blob/master/Searches/IterativeBinarySearch.java)
|
||||||
- [IterativeBinarySearch](https://github.com/TheAlgorithms/Java/blob/master/Searches/IterativeBinarySearch.java)
|
* [IterativeTernarySearch](https://github.com/TheAlgorithms/Java/blob/master/Searches/IterativeTernarySearch.java)
|
||||||
- [IterativeTernarySearch](https://github.com/TheAlgorithms/Java/blob/master/Searches/IterativeTernarySearch.java)
|
* [JumpSearch](https://github.com/TheAlgorithms/Java/blob/master/Searches/JumpSearch.java)
|
||||||
- [JumpSearch](https://github.com/TheAlgorithms/Java/blob/master/Searches/JumpSearch.java)
|
* [LinearSearch](https://github.com/TheAlgorithms/Java/blob/master/Searches/LinearSearch.java)
|
||||||
- [LinearSearch](https://github.com/TheAlgorithms/Java/blob/master/Searches/LinearSearch.java)
|
* [PerfectBinarySearch](https://github.com/TheAlgorithms/Java/blob/master/Searches/PerfectBinarySearch.java)
|
||||||
- [PerfectBinarySearch](https://github.com/TheAlgorithms/Java/blob/master/Searches/PerfectBinarySearch.java)
|
* [SaddlebackSearch](https://github.com/TheAlgorithms/Java/blob/master/Searches/SaddlebackSearch.java)
|
||||||
- [SaddlebackSearch](https://github.com/TheAlgorithms/Java/blob/master/Searches/SaddlebackSearch.java)
|
* [SearchAlgorithm](https://github.com/TheAlgorithms/Java/blob/master/Searches/SearchAlgorithm.java)
|
||||||
- [SearchAlgorithm](https://github.com/TheAlgorithms/Java/blob/master/Searches/SearchAlgorithm.java)
|
* [TernarySearch](https://github.com/TheAlgorithms/Java/blob/master/Searches/TernarySearch.java)
|
||||||
- [TernarySearch](https://github.com/TheAlgorithms/Java/blob/master/Searches/TernarySearch.java)
|
|
||||||
|
|
||||||
## Sorts
|
## Sorts
|
||||||
|
* [BitonicSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/BitonicSort.java)
|
||||||
- [BitonicSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/BitonicSort.java)
|
* [BogoSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/BogoSort.java)
|
||||||
- [BogoSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/BogoSort.java)
|
* [BubbleSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/BubbleSort.java)
|
||||||
- [BubbleSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/BubbleSort.java)
|
* [BubbleSortRecursion](https://github.com/TheAlgorithms/Java/blob/master/Sorts/BubbleSortRecursion.java)
|
||||||
- [BubbleSortRecursion](https://github.com/TheAlgorithms/Java/blob/master/Sorts/BubbleSortRecursion.java)
|
* [BucketSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/BucketSort.java)
|
||||||
- [BucketSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/BucketSort.java)
|
* [CocktailShakerSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/CocktailShakerSort.java)
|
||||||
- [CocktailShakerSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/CocktailShakerSort.java)
|
* [CombSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/CombSort.java)
|
||||||
- [CombSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/CombSort.java)
|
* [CountingSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/CountingSort.java)
|
||||||
- [CountingSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/CountingSort.java)
|
* [CycleSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/CycleSort.java)
|
||||||
- [CycleSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/CycleSort.java)
|
* [GnomeSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/GnomeSort.java)
|
||||||
- [GnomeSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/GnomeSort.java)
|
* [HeapSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/HeapSort.java)
|
||||||
- [HeapSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/HeapSort.java)
|
* [InsertionSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/InsertionSort.java)
|
||||||
- [InsertionSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/InsertionSort.java)
|
* [MergeSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/MergeSort.java)
|
||||||
- [MergeSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/MergeSort.java)
|
* [PancakeSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/PancakeSort.java)
|
||||||
- [PancakeSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/PancakeSort.java)
|
* [QuickSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/QuickSort.java)
|
||||||
- [QuickSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/QuickSort.java)
|
* [RadixSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/RadixSort.java)
|
||||||
- [RadixSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/RadixSort.java)
|
* [SelectionSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/SelectionSort.java)
|
||||||
- [SelectionSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/SelectionSort.java)
|
* [ShellSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/ShellSort.java)
|
||||||
- [ShellSort](https://github.com/TheAlgorithms/Java/blob/master/Sorts/ShellSort.java)
|
* [SortAlgorithm](https://github.com/TheAlgorithms/Java/blob/master/Sorts/SortAlgorithm.java)
|
||||||
- [SortAlgorithm](https://github.com/TheAlgorithms/Java/blob/master/Sorts/SortAlgorithm.java)
|
* [SortUtils](https://github.com/TheAlgorithms/Java/blob/master/Sorts/SortUtils.java)
|
||||||
- [SortUtils](https://github.com/TheAlgorithms/Java/blob/master/Sorts/SortUtils.java)
|
|
||||||
|
|
||||||
## strings
|
## strings
|
||||||
|
* [Alphabetical](https://github.com/TheAlgorithms/Java/blob/master/strings/Alphabetical.java)
|
||||||
- [Alphabetical](https://github.com/TheAlgorithms/Java/blob/master/strings/Alphabetical.java)
|
* [CharactersSame](https://github.com/TheAlgorithms/Java/blob/master/strings/CharactersSame.java)
|
||||||
- [CharactersSame](https://github.com/TheAlgorithms/Java/blob/master/strings/CharactersSame.java)
|
* [CheckAnagrams](https://github.com/TheAlgorithms/Java/blob/master/strings/CheckAnagrams.java)
|
||||||
- [CheckAnagrams](https://github.com/TheAlgorithms/Java/blob/master/strings/CheckAnagrams.java)
|
* [Lower](https://github.com/TheAlgorithms/Java/blob/master/strings/Lower.java)
|
||||||
- [Lower](https://github.com/TheAlgorithms/Java/blob/master/strings/Lower.java)
|
* [Palindrome](https://github.com/TheAlgorithms/Java/blob/master/strings/Palindrome.java)
|
||||||
- [Palindrome](https://github.com/TheAlgorithms/Java/blob/master/strings/Palindrome.java)
|
* [Pangram](https://github.com/TheAlgorithms/Java/blob/master/strings/Pangram.java)
|
||||||
- [Pangram](https://github.com/TheAlgorithms/Java/blob/master/strings/Pangram.java)
|
* [ReverseString](https://github.com/TheAlgorithms/Java/blob/master/strings/ReverseString.java)
|
||||||
- [ReverseString](https://github.com/TheAlgorithms/Java/blob/master/strings/ReverseString.java)
|
* [Rotation](https://github.com/TheAlgorithms/Java/blob/master/strings/Rotation.java)
|
||||||
- [Rotation](https://github.com/TheAlgorithms/Java/blob/master/strings/Rotation.java)
|
* [Upper](https://github.com/TheAlgorithms/Java/blob/master/strings/Upper.java)
|
||||||
- [Upper](https://github.com/TheAlgorithms/Java/blob/master/strings/Upper.java)
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package DataStructures.DynamicArray;
|
package DataStructures.DynamicArray;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements a dynamic array
|
* This class implements a dynamic array
|
||||||
|
@ -1,487 +0,0 @@
|
|||||||
package DataStructures.Graphs;
|
|
||||||
/*
|
|
||||||
Implementation of graph by using hashmap for vertices of class which contains hashmap for vertex and then algos like prims dijktsra ,depth for search and traversal ,breadth for search and traversal ,algo for cycle present or not ,connected or not ,if not connected then connect it
|
|
||||||
Test case
|
|
||||||
Graph gp=new Graph();
|
|
||||||
gp.addVertex("A");
|
|
||||||
gp.addVertex("B");
|
|
||||||
gp.addVertex("C");
|
|
||||||
gp.addVertex("D");
|
|
||||||
gp.addVertex("E");
|
|
||||||
gp.addVertex("F");
|
|
||||||
gp.addVertex("G");
|
|
||||||
gp.addEdge("A", "B", 2);
|
|
||||||
gp.addEdge("A", "D", 10);
|
|
||||||
gp.addEdge("B", "C", 3);
|
|
||||||
gp.addEdge("C", "D", 1);
|
|
||||||
gp.addEdge("D", "E", 8);
|
|
||||||
gp.addEdge("E", "F", 5);
|
|
||||||
gp.addEdge("E", "G", 6);
|
|
||||||
gp.addEdge("F", "G", 4);
|
|
||||||
|
|
||||||
// gp.display();
|
|
||||||
// System.out.println(gp.numVertex());
|
|
||||||
// System.out.println(gp.numEdge());
|
|
||||||
// System.out.println(gp.containsEdge("A", "C"));
|
|
||||||
//
|
|
||||||
// System.out.println(gp.containsEdge("E", "F"));
|
|
||||||
// gp.removeEdge("D", "E");
|
|
||||||
// gp.display();
|
|
||||||
// gp.removeVertex("F");
|
|
||||||
// gp.addVertex("F");
|
|
||||||
// gp.display();
|
|
||||||
// System.out.println(gp.hasPath("A", "F", new HashMap<>()));
|
|
||||||
// System.out.println(gp.dfs("A", "F"));
|
|
||||||
// gp.bft();
|
|
||||||
// gp.dft();
|
|
||||||
// gp.removeEdge("B","C");
|
|
||||||
// gp.removeEdge("F","G");
|
|
||||||
// System.out.println(gp.isConnected());
|
|
||||||
// System.out.println(gp.isCyclic());
|
|
||||||
// System.out.println(gp.isTree());
|
|
||||||
// System.out.println(gp.getConnectedComp());
|
|
||||||
// gp.prims().display();
|
|
||||||
System.out.println(gp.Dijktsra("A"));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import Heaps.GenericHeap;
|
|
||||||
public class Graph {
|
|
||||||
private class vertex{
|
|
||||||
HashMap<String,Integer> nbrs=new HashMap<>();
|
|
||||||
}
|
|
||||||
HashMap<String,vertex> vertcs;
|
|
||||||
public Graph(){
|
|
||||||
vertcs=new HashMap<>();
|
|
||||||
}
|
|
||||||
public int numVertex() {
|
|
||||||
return this.vertcs.size();
|
|
||||||
}
|
|
||||||
public boolean containsVertex(String vname) {
|
|
||||||
return this.vertcs.containsKey(vname);
|
|
||||||
}
|
|
||||||
public void addVertex(String vname) {
|
|
||||||
|
|
||||||
vertex vtx=new vertex();
|
|
||||||
this.vertcs.put(vname,vtx);
|
|
||||||
}
|
|
||||||
public void removeVertex(String vname) {
|
|
||||||
vertex vtx=this.vertcs.get(vname);
|
|
||||||
ArrayList<String> keys=new ArrayList<>(vtx.nbrs.keySet());
|
|
||||||
for(String key:keys) {
|
|
||||||
vertex nbrvtx=this.vertcs.get(key);
|
|
||||||
nbrvtx.nbrs.remove(vname);
|
|
||||||
}
|
|
||||||
this.vertcs.remove(vname);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int numEdge() {
|
|
||||||
int count=0;
|
|
||||||
ArrayList<String> keys=new ArrayList<>(this.vertcs.keySet());
|
|
||||||
for(String key:keys) {
|
|
||||||
vertex vtx=this.vertcs.get(key);
|
|
||||||
count+=vtx.nbrs.size();
|
|
||||||
}
|
|
||||||
return count/2;
|
|
||||||
}
|
|
||||||
public boolean containsEdge(String vname1,String vname2) {
|
|
||||||
vertex vtx1=this.vertcs.get(vname1);
|
|
||||||
vertex vtx2=this.vertcs.get(vname2);
|
|
||||||
if(vtx1==null||vtx2==null||!vtx1.nbrs.containsKey(vname2))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public void addEdge(String vname1,String vname2,int cost) {
|
|
||||||
vertex vtx1=this.vertcs.get(vname1);
|
|
||||||
vertex vtx2=this.vertcs.get(vname2);
|
|
||||||
if(vtx1==null||vtx2==null||vtx1.nbrs.containsKey(vname2))
|
|
||||||
return;
|
|
||||||
vtx1.nbrs.put(vname2,cost);
|
|
||||||
vtx2.nbrs.put(vname1,cost);
|
|
||||||
}
|
|
||||||
public void removeEdge(String vname1,String vname2) {
|
|
||||||
vertex vtx1=this.vertcs.get(vname1);
|
|
||||||
vertex vtx2=this.vertcs.get(vname2);
|
|
||||||
if(vtx1==null||vtx2==null||!vtx1.nbrs.containsKey(vname2))
|
|
||||||
return;
|
|
||||||
vtx1.nbrs.remove(vname2);
|
|
||||||
vtx2.nbrs.remove(vname1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void display() {
|
|
||||||
ArrayList<String> keys=new ArrayList<>(this.vertcs.keySet());
|
|
||||||
for(String key:keys) {
|
|
||||||
vertex vtx=this.vertcs.get(key);
|
|
||||||
System.out.println(key+" := "+vtx.nbrs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasPath(String source ,String dest,HashMap<String,Boolean> processed) {
|
|
||||||
processed.put(source, true);
|
|
||||||
if(containsEdge(source,dest)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
vertex vtx=this.vertcs.get(source);
|
|
||||||
ArrayList<String> keys=new ArrayList<>(vtx.nbrs.keySet());
|
|
||||||
for(String key:keys) {
|
|
||||||
if(!processed.containsKey(key) && hasPath(key,dest,processed))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
|
||||||
private class pair{
|
|
||||||
String vname;
|
|
||||||
String psf;
|
|
||||||
}
|
|
||||||
public boolean bfs(String source,String dest) { // breadth first search
|
|
||||||
HashMap<String ,Boolean> processed=new HashMap<>();
|
|
||||||
|
|
||||||
LinkedList<pair> queue=new LinkedList<>();
|
|
||||||
pair sp=new pair();
|
|
||||||
sp.vname=source;
|
|
||||||
sp.psf=source;
|
|
||||||
queue.addLast(sp);
|
|
||||||
|
|
||||||
while(!queue.isEmpty()) {
|
|
||||||
pair rp=queue.removeFirst();
|
|
||||||
if(processed.containsKey(rp.vname))
|
|
||||||
continue;
|
|
||||||
processed.put(rp.vname,true);
|
|
||||||
|
|
||||||
if(containsEdge(rp.vname,dest)) {
|
|
||||||
System.out.println(rp.psf+dest);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
vertex vtx=this.vertcs.get(rp.vname);
|
|
||||||
ArrayList<String> nbrs=new ArrayList<>(vtx.nbrs.keySet());
|
|
||||||
for(String nbr:nbrs) {
|
|
||||||
if(!processed.containsKey(nbr)) {
|
|
||||||
pair np=new pair();
|
|
||||||
np.vname=nbr;
|
|
||||||
np.psf=rp.psf+nbr;
|
|
||||||
queue.addLast(np);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public boolean dfs(String source,String dest) { //deapth first search
|
|
||||||
LinkedList<pair> stack=new LinkedList<>();
|
|
||||||
HashMap<String,Boolean> processed=new HashMap<>();
|
|
||||||
pair sp=new pair();
|
|
||||||
sp.vname=source;
|
|
||||||
sp.psf=source;
|
|
||||||
stack.addFirst(sp);
|
|
||||||
while(!stack.isEmpty()) {
|
|
||||||
pair rp=stack.removeFirst();
|
|
||||||
if(processed.containsKey(rp.vname))
|
|
||||||
continue;
|
|
||||||
processed.put(rp.vname,true);
|
|
||||||
if(containsEdge(rp.vname,dest)) {
|
|
||||||
System.out.println(rp.psf+dest);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
vertex vtx=this.vertcs.get(rp.vname);
|
|
||||||
ArrayList<String > nbrs=new ArrayList<>(vtx.nbrs.keySet());
|
|
||||||
for(String nbr:nbrs) {
|
|
||||||
if(!processed.containsKey(nbr)) {
|
|
||||||
pair np=new pair();
|
|
||||||
np.vname=nbr;
|
|
||||||
np.psf=rp.psf+nbr;
|
|
||||||
stack.addFirst(np);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public void bft() { //breadth first traversal
|
|
||||||
HashMap<String ,Boolean> processed=new HashMap<>();
|
|
||||||
LinkedList<pair> queue=new LinkedList<>();
|
|
||||||
ArrayList<String> keys=new ArrayList<>(this.vertcs.keySet());
|
|
||||||
for(String key:keys) {
|
|
||||||
if(processed.containsKey(key))
|
|
||||||
continue;
|
|
||||||
pair sp=new pair();
|
|
||||||
sp.vname=key;
|
|
||||||
sp.psf=key;
|
|
||||||
queue.addLast(sp);
|
|
||||||
|
|
||||||
while(!queue.isEmpty()) {
|
|
||||||
pair rp=queue.removeFirst();
|
|
||||||
if(processed.containsKey(rp.vname))
|
|
||||||
continue;
|
|
||||||
processed.put(rp.vname,true);
|
|
||||||
|
|
||||||
System.out.println(rp.vname+" via "+rp.psf);
|
|
||||||
|
|
||||||
vertex vtx=this.vertcs.get(rp.vname);
|
|
||||||
ArrayList<String> nbrs=new ArrayList<>(vtx.nbrs.keySet());
|
|
||||||
for(String nbr:nbrs) {
|
|
||||||
if(!processed.containsKey(nbr)) {
|
|
||||||
pair np=new pair();
|
|
||||||
np.vname=nbr;
|
|
||||||
np.psf=rp.psf+nbr;
|
|
||||||
queue.addLast(np);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void dft() { //deapt first traversal
|
|
||||||
HashMap<String ,Boolean> processed=new HashMap<>();
|
|
||||||
LinkedList<pair> stack=new LinkedList<>();
|
|
||||||
ArrayList<String> keys=new ArrayList<>(this.vertcs.keySet());
|
|
||||||
for(String key:keys) {
|
|
||||||
pair sp=new pair();
|
|
||||||
sp.vname=key;
|
|
||||||
sp.psf=key;
|
|
||||||
stack.addFirst(sp);
|
|
||||||
|
|
||||||
while(!stack.isEmpty()) {
|
|
||||||
pair rp=stack.removeFirst();
|
|
||||||
if(processed.containsKey(rp.vname))
|
|
||||||
continue;
|
|
||||||
processed.put(rp.vname,true);
|
|
||||||
|
|
||||||
System.out.println(rp.vname+" via "+rp.psf);
|
|
||||||
|
|
||||||
vertex vtx=this.vertcs.get(rp.vname);
|
|
||||||
ArrayList<String> nbrs=new ArrayList<>(vtx.nbrs.keySet());
|
|
||||||
for(String nbr:nbrs) {
|
|
||||||
if(!processed.containsKey(nbr)) {
|
|
||||||
pair np=new pair();
|
|
||||||
np.vname=nbr;
|
|
||||||
np.psf=rp.psf+nbr;
|
|
||||||
stack.addFirst(np);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isCyclic() {
|
|
||||||
HashMap<String ,Boolean> processed=new HashMap<>();
|
|
||||||
LinkedList<pair> queue=new LinkedList<>();
|
|
||||||
ArrayList<String> keys=new ArrayList<>(this.vertcs.keySet());
|
|
||||||
for(String key:keys) {
|
|
||||||
if(processed.containsKey(key))
|
|
||||||
continue;
|
|
||||||
pair sp=new pair();
|
|
||||||
sp.vname=key;
|
|
||||||
sp.psf=key;
|
|
||||||
queue.addLast(sp);
|
|
||||||
|
|
||||||
while(!queue.isEmpty()) {
|
|
||||||
pair rp=queue.removeFirst();
|
|
||||||
if(processed.containsKey(rp.vname))
|
|
||||||
return true;
|
|
||||||
processed.put(rp.vname,true);
|
|
||||||
|
|
||||||
vertex vtx=this.vertcs.get(rp.vname);
|
|
||||||
ArrayList<String> nbrs=new ArrayList<>(vtx.nbrs.keySet());
|
|
||||||
for(String nbr:nbrs) {
|
|
||||||
if(!processed.containsKey(nbr)) {
|
|
||||||
pair np=new pair();
|
|
||||||
np.vname=nbr;
|
|
||||||
np.psf=rp.psf+nbr;
|
|
||||||
queue.addLast(np);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public boolean isConnected() {
|
|
||||||
int flag=0;
|
|
||||||
HashMap<String ,Boolean> processed=new HashMap<>();
|
|
||||||
LinkedList<pair> queue=new LinkedList<>();
|
|
||||||
ArrayList<String> keys=new ArrayList<>(this.vertcs.keySet());
|
|
||||||
for(String key:keys) {
|
|
||||||
if(processed.containsKey(key))
|
|
||||||
continue;
|
|
||||||
flag++;
|
|
||||||
pair sp=new pair();
|
|
||||||
sp.vname=key;
|
|
||||||
sp.psf=key;
|
|
||||||
queue.addLast(sp);
|
|
||||||
|
|
||||||
while(!queue.isEmpty()) {
|
|
||||||
pair rp=queue.removeFirst();
|
|
||||||
if(processed.containsKey(rp.vname))
|
|
||||||
continue;
|
|
||||||
processed.put(rp.vname,true);
|
|
||||||
|
|
||||||
vertex vtx=this.vertcs.get(rp.vname);
|
|
||||||
ArrayList<String> nbrs=new ArrayList<>(vtx.nbrs.keySet());
|
|
||||||
for(String nbr:nbrs) {
|
|
||||||
if(!processed.containsKey(nbr)) {
|
|
||||||
pair np=new pair();
|
|
||||||
np.vname=nbr;
|
|
||||||
np.psf=rp.psf+nbr;
|
|
||||||
queue.addLast(np);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(flag>=2)
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public boolean isTree() {
|
|
||||||
return !isCyclic()&&isConnected();
|
|
||||||
}
|
|
||||||
public ArrayList<ArrayList<String>> getConnectedComp() {
|
|
||||||
ArrayList<ArrayList<String>> ans=new ArrayList<>();
|
|
||||||
HashMap<String ,Boolean> processed=new HashMap<>();
|
|
||||||
LinkedList<pair> queue=new LinkedList<>();
|
|
||||||
ArrayList<String> keys=new ArrayList<>(this.vertcs.keySet());
|
|
||||||
for(String key:keys) {
|
|
||||||
if(processed.containsKey(key))
|
|
||||||
continue;
|
|
||||||
ArrayList<String> subans=new ArrayList<>();
|
|
||||||
pair sp=new pair();
|
|
||||||
sp.vname=key;
|
|
||||||
sp.psf=key;
|
|
||||||
queue.addLast(sp);
|
|
||||||
|
|
||||||
while(!queue.isEmpty()) {
|
|
||||||
pair rp=queue.removeFirst();
|
|
||||||
if(processed.containsKey(rp.vname))
|
|
||||||
continue;
|
|
||||||
processed.put(rp.vname,true);
|
|
||||||
|
|
||||||
subans.add(rp.vname);
|
|
||||||
|
|
||||||
vertex vtx=this.vertcs.get(rp.vname);
|
|
||||||
ArrayList<String> nbrs=new ArrayList<>(vtx.nbrs.keySet());
|
|
||||||
for(String nbr:nbrs) {
|
|
||||||
if(!processed.containsKey(nbr)) {
|
|
||||||
pair np=new pair();
|
|
||||||
np.vname=nbr;
|
|
||||||
np.psf=rp.psf+nbr;
|
|
||||||
queue.addLast(np);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ans.add(subans);
|
|
||||||
}
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
private class PrimsPair implements Comparable<PrimsPair>{
|
|
||||||
String vname;
|
|
||||||
String acqvname;
|
|
||||||
int cost;
|
|
||||||
public int compareTo(PrimsPair o) {
|
|
||||||
return o.cost-this.cost;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
public Graph prims() {
|
|
||||||
HashMap<String ,PrimsPair> map=new HashMap<>();
|
|
||||||
GenericHeap<PrimsPair> heap=new GenericHeap<>();
|
|
||||||
Graph mst=new Graph();
|
|
||||||
for(String vrtx:this.vertcs.keySet()) {
|
|
||||||
PrimsPair np=new PrimsPair();
|
|
||||||
np.acqvname=null;
|
|
||||||
np.vname=vrtx;
|
|
||||||
np.cost=Integer.MAX_VALUE;
|
|
||||||
heap.add(np);
|
|
||||||
map.put(vrtx, np);
|
|
||||||
}
|
|
||||||
while(!heap.isEmpty()) {
|
|
||||||
PrimsPair rp=heap.remove();
|
|
||||||
map.remove(rp.vname);
|
|
||||||
|
|
||||||
if(rp.acqvname==null) {
|
|
||||||
mst.addVertex(rp.vname);
|
|
||||||
}else {
|
|
||||||
mst.addVertex(rp.vname);
|
|
||||||
mst.addEdge(rp.vname, rp.acqvname, rp.cost);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(String nbr:this.vertcs.get(rp.vname).nbrs.keySet()) {
|
|
||||||
if(map.containsKey(nbr)) {
|
|
||||||
//old cost that is from diff path stored in map
|
|
||||||
int oc=map.get(nbr).cost;
|
|
||||||
// cost that present vname need cost to go to nbr
|
|
||||||
int nc=this.vertcs.get(rp.vname).nbrs.get(nbr);
|
|
||||||
if(nc<oc) {
|
|
||||||
PrimsPair gp=map.get(nbr);
|
|
||||||
gp.acqvname=rp.vname;
|
|
||||||
gp.cost=nc;
|
|
||||||
heap.updatePriority(gp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return mst;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DijktsraPair implements Comparable<DijktsraPair>{
|
|
||||||
String vname;
|
|
||||||
String psf;
|
|
||||||
int cost;
|
|
||||||
public int compareTo(DijktsraPair o) {
|
|
||||||
return o.cost-this.cost;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
public HashMap<String,Integer> Dijktsra(String source) {
|
|
||||||
HashMap<String ,DijktsraPair> map=new HashMap<>();
|
|
||||||
GenericHeap<DijktsraPair> heap=new GenericHeap<>();
|
|
||||||
HashMap<String,Integer> ans =new HashMap<>();
|
|
||||||
for(String vrtx:this.vertcs.keySet()) {
|
|
||||||
DijktsraPair np=new DijktsraPair();
|
|
||||||
np.psf="";
|
|
||||||
np.vname=vrtx;
|
|
||||||
np.cost=Integer.MAX_VALUE;
|
|
||||||
if(vrtx==source) {
|
|
||||||
np.cost=0;
|
|
||||||
np.psf=source;
|
|
||||||
}
|
|
||||||
heap.add(np);
|
|
||||||
map.put(vrtx, np);
|
|
||||||
}
|
|
||||||
while(!heap.isEmpty()) {
|
|
||||||
DijktsraPair rp=heap.remove();
|
|
||||||
map.remove(rp.vname);
|
|
||||||
|
|
||||||
ans.put(rp.vname,rp.cost);
|
|
||||||
|
|
||||||
for(String nbr:this.vertcs.get(rp.vname).nbrs.keySet()) {
|
|
||||||
if(map.containsKey(nbr)) {
|
|
||||||
//old cost that is from diff path stored in map
|
|
||||||
int oc=map.get(nbr).cost;
|
|
||||||
// cost that present vname need cost to go to nbr
|
|
||||||
int nc=rp.cost+this.vertcs.get(rp.vname).nbrs.get(nbr);
|
|
||||||
if(nc<oc) {
|
|
||||||
DijktsraPair gp=map.get(nbr);
|
|
||||||
gp.psf=rp.psf+nbr;
|
|
||||||
gp.cost=nc;
|
|
||||||
heap.updatePriority(gp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return ans;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,153 +0,0 @@
|
|||||||
package DataStructures.Lists;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This class implements a SinglyLinked List.
|
|
||||||
* A linked list is similar to an array, it hold values.
|
|
||||||
* However, links in a linked list do not have indexes. With
|
|
||||||
* a linked list you do not need to predetermine it's size as
|
|
||||||
* it grows and shrinks as it is edited.
|
|
||||||
*it has functions called mid that gives node at mid
|
|
||||||
* in addn to linked list there is algo that
|
|
||||||
* construct a linked list with alternate sums of linked list
|
|
||||||
* and added to new one and add mid value
|
|
||||||
* i.e sum of first and last value of inital list
|
|
||||||
|
|
||||||
Test Case:
|
|
||||||
|
|
||||||
|
|
||||||
LinkedList LL1 = new LinkedList();
|
|
||||||
Scanner scn=new Scanner(System.in);
|
|
||||||
int numNodes=scn.nextInt();
|
|
||||||
for(int i=0;i<2*numNodes;i++) {
|
|
||||||
LL1.addLast(scn.nextInt());
|
|
||||||
}
|
|
||||||
LL1.display();
|
|
||||||
LinkedList LL2=new LinkedList();
|
|
||||||
LL2.formLL2(LL1);
|
|
||||||
LL2.display();
|
|
||||||
LinkedList LL3=new LinkedList();
|
|
||||||
LL3.formLL3(LL1);
|
|
||||||
LL3.display();
|
|
||||||
Node MID=LL1.midValue();
|
|
||||||
System.out.println(MID.data);
|
|
||||||
LinkedList updLL1=new LinkedList();
|
|
||||||
updLL1.formRes(LL1,LL2,LL3,MID);
|
|
||||||
updLL1.display();
|
|
||||||
updLL1.size();
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.lang.*;
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
public class LinkedList {
|
|
||||||
|
|
||||||
private class Node{
|
|
||||||
int data;
|
|
||||||
Node next;
|
|
||||||
|
|
||||||
Node(int data) {
|
|
||||||
this.data = data;
|
|
||||||
this.next = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Node head;
|
|
||||||
private Node tail;
|
|
||||||
private int size;
|
|
||||||
|
|
||||||
public LinkedList() {
|
|
||||||
head = null;
|
|
||||||
tail = null;
|
|
||||||
size = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addLast(int data) {
|
|
||||||
Node newNode = new Node(data);
|
|
||||||
|
|
||||||
if(this.head == null) {
|
|
||||||
this.head = newNode;
|
|
||||||
this.tail = newNode;
|
|
||||||
this.size++;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.tail.next = newNode;
|
|
||||||
this.tail = newNode;
|
|
||||||
this.size++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void display() {
|
|
||||||
Node current = this.head;
|
|
||||||
if(this.head == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while(current != null) {
|
|
||||||
System.out.print(current.data + " ");
|
|
||||||
current = current.next;
|
|
||||||
}
|
|
||||||
System.out.println();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void formLL2(LinkedList LL1) {
|
|
||||||
Node current=LL1.head;
|
|
||||||
while(current.next!=null&¤t.next.next!=null) {
|
|
||||||
int sum=current.data+current.next.next.data;
|
|
||||||
this.addLast(sum);
|
|
||||||
current=current.next.next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void formLL3(LinkedList LL1) {
|
|
||||||
Node current=LL1.head.next;
|
|
||||||
while(current.next!=null&¤t.next.next!=null) {
|
|
||||||
int sum=current.data+current.next.next.data;
|
|
||||||
this.addLast(sum);
|
|
||||||
current=current.next.next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Node mid() {
|
|
||||||
Node slow=this.head;
|
|
||||||
Node fast=this.head;
|
|
||||||
while(fast.next!=null && fast.next.next!=null) {
|
|
||||||
slow=slow.next;
|
|
||||||
fast=fast.next.next;
|
|
||||||
}
|
|
||||||
return slow;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Node midValue() {
|
|
||||||
int sum=this.head.data+this.tail.data;
|
|
||||||
Node mid=new Node(sum);
|
|
||||||
return mid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void formRes(LinkedList LL1,LinkedList LL2,LinkedList LL3,Node MID) {
|
|
||||||
Node LL1mid=LL1.mid();
|
|
||||||
Node currentLL1=LL1.head;
|
|
||||||
Node currentLL2=LL2.head;
|
|
||||||
Node currentLL3=LL3.head;
|
|
||||||
while(currentLL1!=null) {
|
|
||||||
this.addLast(currentLL1.data);
|
|
||||||
|
|
||||||
if(currentLL2!=null) {
|
|
||||||
this.addLast(currentLL2.data);
|
|
||||||
currentLL2=currentLL2.next;
|
|
||||||
}else if(currentLL1.equals(LL1mid)) {
|
|
||||||
this.addLast(MID.data);
|
|
||||||
}
|
|
||||||
else if(currentLL2==null&¤tLL3!=null) {
|
|
||||||
this.addLast(currentLL3.data);
|
|
||||||
currentLL3=currentLL3.next;
|
|
||||||
}
|
|
||||||
currentLL1=currentLL1.next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void size() {
|
|
||||||
System.out.println(this.size);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
package test;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
class LongestPalindromicSubsequenceTests {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void test1() {
|
|
||||||
assertEquals(LongestPalindromicSubsequence.LPS(""), "");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void test2() {
|
|
||||||
assertEquals(LongestPalindromicSubsequence.LPS("A"), "A");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void test3() {
|
|
||||||
assertEquals(LongestPalindromicSubsequence.LPS("BABCBAB"), "BABCBAB");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void test4() {
|
|
||||||
assertEquals(LongestPalindromicSubsequence.LPS("BBABCBCAB"), "BABCBAB");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void test5() {
|
|
||||||
assertEquals(LongestPalindromicSubsequence.LPS("AAAAAAAAAAAAAAAAAAAAAAAA"), "AAAAAAAAAAAAAAAAAAAAAAAA");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
package Misc;
|
|
||||||
|
|
||||||
public class HeapSort {
|
|
||||||
public void sort(int[] arr) {
|
|
||||||
int n = arr.length;
|
|
||||||
|
|
||||||
// Build heap (rearrange array)
|
|
||||||
for (int i = n / 2 - 1; i >= 0; i--)
|
|
||||||
heapify(arr, n, i);
|
|
||||||
|
|
||||||
// One by one extract an element from heap
|
|
||||||
for (int i = n - 1; i >= 0; i--) {
|
|
||||||
// Move current root to end
|
|
||||||
int temp = arr[0];
|
|
||||||
arr[0] = arr[i];
|
|
||||||
arr[i] = temp;
|
|
||||||
|
|
||||||
// call max heapify on the reduced heap
|
|
||||||
heapify(arr, i, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// To heapify a subtree rooted with node i which is
|
|
||||||
// an index in arr[]. n is size of heap
|
|
||||||
void heapify(int[] arr, int n, int i) {
|
|
||||||
int largest = i; // Initialize largest as root
|
|
||||||
int l = 2 * i + 1; // left = 2*i + 1
|
|
||||||
int r = 2 * i + 2; // right = 2*i + 2
|
|
||||||
|
|
||||||
// If left child is larger than root
|
|
||||||
if (l < n && arr[l] > arr[largest])
|
|
||||||
largest = l;
|
|
||||||
|
|
||||||
// If right child is larger than largest so far
|
|
||||||
if (r < n && arr[r] > arr[largest])
|
|
||||||
largest = r;
|
|
||||||
|
|
||||||
// If largest is not root
|
|
||||||
if (largest != i) {
|
|
||||||
int swap = arr[i];
|
|
||||||
arr[i] = arr[largest];
|
|
||||||
arr[largest] = swap;
|
|
||||||
|
|
||||||
// Recursively heapify the affected sub-tree
|
|
||||||
heapify(arr, n, largest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* A utility function to print array of size n */
|
|
||||||
static void printArray(int[] arr) {
|
|
||||||
int n = arr.length;
|
|
||||||
for (int i = 0; i < n; ++i)
|
|
||||||
System.out.print(arr[i] + " ");
|
|
||||||
System.out.println();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Driver program
|
|
||||||
public static void main(String args[]) {
|
|
||||||
int arr[] = {12, 11, 13, 5, 6, 7};
|
|
||||||
|
|
||||||
heap_sort ob = new heap_sort();
|
|
||||||
ob.sort(arr);
|
|
||||||
|
|
||||||
System.out.println("Sorted array is");
|
|
||||||
printArray(arr);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
package Others;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rotation of array without using extra space
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author Ujjawal Joshi
|
|
||||||
* @date 2020.05.18
|
|
||||||
*
|
|
||||||
* Test Cases:
|
|
||||||
|
|
||||||
Input:
|
|
||||||
2 //Size of matrix
|
|
||||||
1 2
|
|
||||||
3 4
|
|
||||||
Output:
|
|
||||||
3 1
|
|
||||||
4 2
|
|
||||||
------------------------------
|
|
||||||
Input:
|
|
||||||
3 //Size of matrix
|
|
||||||
1 2 3
|
|
||||||
4 5 6
|
|
||||||
7 8 9
|
|
||||||
Output:
|
|
||||||
7 4 1
|
|
||||||
8 5 2
|
|
||||||
9 6 3
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class main{
|
|
||||||
public static void main(String[] args)
|
|
||||||
{
|
|
||||||
Scanner sc=new Scanner(System.in);
|
|
||||||
int n=sc.nextInt();
|
|
||||||
int a[][]=new int[n][n];
|
|
||||||
|
|
||||||
for(int i=0;i<n;i++)
|
|
||||||
{
|
|
||||||
for(int j=0;j<n;j++)
|
|
||||||
{
|
|
||||||
a[i][j]=sc.nextInt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int temp=0;
|
|
||||||
|
|
||||||
// Rotation of array by swapping their values
|
|
||||||
for(int i=0;i<n/2;i++)
|
|
||||||
{
|
|
||||||
for(int j=i;j<n-i-1;j++)
|
|
||||||
{
|
|
||||||
temp=a[i][j];
|
|
||||||
a[i][j]=a[n-j-1][i];
|
|
||||||
a[n-j-1][i]=a[n-i-1][n-j-1];
|
|
||||||
a[n-i-1][n-j-1]=a[j][n-i-1];
|
|
||||||
a[j][n-i-1]=temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// printing of sorted array
|
|
||||||
for(int i=0;i<n;i++){
|
|
||||||
for(int j=0;j<n;j++){
|
|
||||||
System.out.print(a[i][j]+" ");
|
|
||||||
|
|
||||||
}
|
|
||||||
System.out.println();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -26,7 +26,7 @@ import java.util.Arrays;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
class threesum{
|
class ThreeSum{
|
||||||
public static void main(String args[])
|
public static void main(String args[])
|
||||||
{
|
{
|
||||||
Scanner sc =new Scanner(System.in);
|
Scanner sc =new Scanner(System.in);
|
@ -104,10 +104,6 @@ public class Caesar {
|
|||||||
return c >= 'a' && c <= 'z';
|
return c >= 'a' && c <= 'z';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @deprecated TODO remove main and make JUnit Testing
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Scanner input = new Scanner(System.in);
|
Scanner input = new Scanner(System.in);
|
||||||
System.out.println("Please enter the message (Latin Alphabet)");
|
System.out.println("Please enter the message (Latin Alphabet)");
|
||||||
|
@ -9,13 +9,6 @@ import javax.swing.JOptionPane;
|
|||||||
*/
|
*/
|
||||||
public final class RSA {
|
public final class RSA {
|
||||||
|
|
||||||
/**
|
|
||||||
* Trivial test program.
|
|
||||||
*
|
|
||||||
* @param args
|
|
||||||
* @deprecated TODO remove main and make JUnit Testing or any other
|
|
||||||
* methodology
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
RSA rsa = new RSA(1024);
|
RSA rsa = new RSA(1024);
|
||||||
|
Reference in New Issue
Block a user