From a81fb32e6cdd739889e115761694d0c11bac7b29 Mon Sep 17 00:00:00 2001 From: StarDxxx <36352922+StarDxxx@users.noreply.github.com> Date: Sat, 8 Jun 2024 19:37:20 +0800 Subject: [PATCH] style: enable `TypeName` (#5214) * style: enable `TypeName` in checkstyle * style: enable `TypeName` in checkstyle * Update directory * style: use proper formatting --------- Co-authored-by: StarDxxx Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com> --- DIRECTORY.md | 26 ++++++++++--------- checkstyle.xml | 2 +- pmd-exclude.properties | 2 +- .../graphs/{A_Star.java => AStar.java} | 4 +-- .../graphs/DIJSKSTRAS_ALGORITHM.java | 4 +-- ...dlist.java => MergeKSortedLinkedlist.java} | 2 +- .../datastructures/lists/README.md | 2 +- ...rixTranspose.java => MatrixTranspose.java} | 4 +-- .../{countSetBits.java => CountSetBits.java} | 4 +-- .../others/RotateMatrixBy90Degrees.java | 4 +-- ...ava => SortOrderAgnosticBinarySearch.java} | 4 +-- ...java => LongestNonRepeativeSubstring.java} | 4 +-- ...{zigZagPattern.java => ZigZagPattern.java} | 4 +-- ...mbStairsTest.java => ClimbStairsTest.java} | 2 +- .../others/CountSetBitsTest.java | 17 ++++++++++++ .../others/countSetBitsTest.java | 17 ------------ ...=> SortOrderAgnosticBinarySearchTest.java} | 6 ++--- ... => LongestNonRepeativeSubstringTest.java} | 6 ++--- ...atternTest.java => ZigZagPatternTest.java} | 6 ++--- 19 files changed, 61 insertions(+), 59 deletions(-) rename src/main/java/com/thealgorithms/datastructures/graphs/{A_Star.java => AStar.java} (99%) rename src/main/java/com/thealgorithms/datastructures/lists/{Merge_K_SortedLinkedlist.java => MergeKSortedLinkedlist.java} (96%) rename src/main/java/com/thealgorithms/misc/{matrixTranspose.java => MatrixTranspose.java} (96%) rename src/main/java/com/thealgorithms/others/{countSetBits.java => CountSetBits.java} (95%) rename src/main/java/com/thealgorithms/searches/{sortOrderAgnosticBinarySearch.java => SortOrderAgnosticBinarySearch.java} (90%) rename src/main/java/com/thealgorithms/strings/{longestNonRepeativeSubstring.java => LongestNonRepeativeSubstring.java} (93%) rename src/main/java/com/thealgorithms/strings/zigZagPattern/{zigZagPattern.java => ZigZagPattern.java} (95%) rename src/test/java/com/thealgorithms/dynamicprogramming/{climbStairsTest.java => ClimbStairsTest.java} (95%) create mode 100644 src/test/java/com/thealgorithms/others/CountSetBitsTest.java delete mode 100644 src/test/java/com/thealgorithms/others/countSetBitsTest.java rename src/test/java/com/thealgorithms/searches/{sortOrderAgnosticBinarySearchTest.java => SortOrderAgnosticBinarySearchTest.java} (75%) rename src/test/java/com/thealgorithms/strings/{longestNonRepeativeSubstringTest.java => LongestNonRepeativeSubstringTest.java} (64%) rename src/test/java/com/thealgorithms/strings/zigZagPattern/{zigZagPatternTest.java => ZigZagPatternTest.java} (67%) diff --git a/DIRECTORY.md b/DIRECTORY.md index c8b38bb2..7c46336f 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -18,6 +18,7 @@ * [ParenthesesGenerator](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/backtracking/ParenthesesGenerator.java) * [Permutation](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/backtracking/Permutation.java) * [PowerSum](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/backtracking/PowerSum.java) + * [SubsequenceFinder](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/backtracking/SubsequenceFinder.java) * [WordSearch](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/backtracking/WordSearch.java) * bitmanipulation * [BitSwap](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/bitmanipulation/BitSwap.java) @@ -96,7 +97,7 @@ * dynamicarray * [DynamicArray](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/datastructures/dynamicarray/DynamicArray.java) * graphs - * [A Star](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/datastructures/graphs/A_Star.java) + * [AStar](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/datastructures/graphs/AStar.java) * [BellmanFord](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/datastructures/graphs/BellmanFord.java) * [BipartiteGrapfDFS](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/datastructures/graphs/BipartiteGrapfDFS.java) * [BoruvkaAlgorithm](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/datastructures/graphs/BoruvkaAlgorithm.java) @@ -141,7 +142,7 @@ * [CreateAndDetectLoop](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/datastructures/lists/CreateAndDetectLoop.java) * [CursorLinkedList](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/datastructures/lists/CursorLinkedList.java) * [DoublyLinkedList](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/datastructures/lists/DoublyLinkedList.java) - * [Merge K SortedLinkedlist](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/datastructures/lists/Merge_K_SortedLinkedlist.java) + * [MergeKSortedLinkedlist](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/datastructures/lists/MergeKSortedLinkedlist.java) * [MergeSortedArrayList](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/datastructures/lists/MergeSortedArrayList.java) * [MergeSortedSinglyLinkedList](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/datastructures/lists/MergeSortedSinglyLinkedList.java) * [QuickSortLinkedList](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/datastructures/lists/QuickSortLinkedList.java) @@ -376,7 +377,7 @@ * [ColorContrastRatio](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/misc/ColorContrastRatio.java) * [InverseOfMatrix](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/misc/InverseOfMatrix.java) * [MapReduce](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/misc/MapReduce.java) - * [matrixTranspose](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/misc/matrixTranspose.java) + * [MatrixTranspose](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/misc/MatrixTranspose.java) * [MedianOfMatrix](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/misc/MedianOfMatrix.java) * [MedianOfRunningArray](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/misc/MedianOfRunningArray.java) * [MedianOfRunningArrayByte](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/misc/MedianOfRunningArrayByte.java) @@ -403,7 +404,7 @@ * [HammingDistance](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/others/cn/HammingDistance.java) * [Conway](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/others/Conway.java) * [CountChar](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/others/CountChar.java) - * [countSetBits](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/others/countSetBits.java) + * [CountSetBits](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/others/CountSetBits.java) * [CountWords](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/others/CountWords.java) * [CRC16](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/others/CRC16.java) * [CRC32](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/others/CRC32.java) @@ -478,7 +479,7 @@ * [RowColumnWiseSorted2dArrayBinarySearch](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/searches/RowColumnWiseSorted2dArrayBinarySearch.java) * [SaddlebackSearch](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/searches/SaddlebackSearch.java) * [SearchInARowAndColWiseSortedMatrix](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/searches/SearchInARowAndColWiseSortedMatrix.java) - * [sortOrderAgnosticBinarySearch](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/searches/sortOrderAgnosticBinarySearch.java) + * [SortOrderAgnosticBinarySearch](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/searches/SortOrderAgnosticBinarySearch.java) * [SquareRootBinarySearch](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/searches/SquareRootBinarySearch.java) * [TernarySearch](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/searches/TernarySearch.java) * [UnionFind](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/searches/UnionFind.java) @@ -549,7 +550,7 @@ * [HorspoolSearch](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/strings/HorspoolSearch.java) * [Isomorphic](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/strings/Isomorphic.java) * [LetterCombinationsOfPhoneNumber](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/strings/LetterCombinationsOfPhoneNumber.java) - * [longestNonRepeativeSubstring](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/strings/longestNonRepeativeSubstring.java) + * [LongestNonRepeativeSubstring](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/strings/LongestNonRepeativeSubstring.java) * [LongestPalindromicSubstring](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/strings/LongestPalindromicSubstring.java) * [Lower](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/strings/Lower.java) * [MyAtoi](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/strings/MyAtoi.java) @@ -565,7 +566,7 @@ * [ValidParentheses](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/strings/ValidParentheses.java) * [WordLadder](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/strings/WordLadder.java) * zigZagPattern - * [zigZagPattern](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/strings/zigZagPattern/zigZagPattern.java) + * [ZigZagPattern](https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/strings/zigZagPattern/ZigZagPattern.java) * test * java * com @@ -580,6 +581,7 @@ * [ParenthesesGeneratorTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/backtracking/ParenthesesGeneratorTest.java) * [PermutationTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/backtracking/PermutationTest.java) * [PowerSumTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/backtracking/PowerSumTest.java) + * [SubsequenceFinderTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/backtracking/SubsequenceFinderTest.java) * [WordSearchTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/backtracking/WordSearchTest.java) * bitmanipulation * [BitSwapTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/bitmanipulation/BitSwapTest.java) @@ -684,7 +686,7 @@ * [StrassenMatrixMultiplicationTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/divideandconquer/StrassenMatrixMultiplicationTest.java) * dynamicprogramming * [CatalanNumberTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/dynamicprogramming/CatalanNumberTest.java) - * [climbStairsTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/dynamicprogramming/climbStairsTest.java) + * [ClimbStairsTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/dynamicprogramming/ClimbStairsTest.java) * [EggDroppingTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/dynamicprogramming/EggDroppingTest.java) * [KnapsackMemoizationTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/dynamicprogramming/KnapsackMemoizationTest.java) * [KnapsackTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/dynamicprogramming/KnapsackTest.java) @@ -812,7 +814,7 @@ * [ConwayTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/others/ConwayTest.java) * [CountCharTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/others/CountCharTest.java) * [CountFriendsPairingTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/others/CountFriendsPairingTest.java) - * [countSetBitsTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/others/countSetBitsTest.java) + * [CountSetBitsTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/others/CountSetBitsTest.java) * [CountWordsTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/others/CountWordsTest.java) * [CRC16Test](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/others/CRC16Test.java) * [CRCAlgorithmTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/others/CRCAlgorithmTest.java) @@ -848,7 +850,7 @@ * [RabinKarpAlgorithmTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/searches/RabinKarpAlgorithmTest.java) * [RecursiveBinarySearchTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/searches/RecursiveBinarySearchTest.java) * [RowColumnWiseSorted2dArrayBinarySearchTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/searches/RowColumnWiseSorted2dArrayBinarySearchTest.java) - * [sortOrderAgnosticBinarySearchTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/searches/sortOrderAgnosticBinarySearchTest.java) + * [SortOrderAgnosticBinarySearchTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/searches/SortOrderAgnosticBinarySearchTest.java) * [TestSearchInARowAndColWiseSortedMatrix](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/searches/TestSearchInARowAndColWiseSortedMatrix.java) * sorts * [BeadSortTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/sorts/BeadSortTest.java) @@ -896,7 +898,7 @@ * [HorspoolSearchTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/strings/HorspoolSearchTest.java) * [IsomorphicTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/strings/IsomorphicTest.java) * [LetterCombinationsOfPhoneNumberTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/strings/LetterCombinationsOfPhoneNumberTest.java) - * [longestNonRepeativeSubstringTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/strings/longestNonRepeativeSubstringTest.java) + * [LongestNonRepeativeSubstringTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/strings/LongestNonRepeativeSubstringTest.java) * [LowerTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/strings/LowerTest.java) * [MyAtoiTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/strings/MyAtoiTest.java) * [PalindromeTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/strings/PalindromeTest.java) @@ -910,4 +912,4 @@ * [ValidParenthesesTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/strings/ValidParenthesesTest.java) * [WordLadderTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/strings/WordLadderTest.java) * zigZagPattern - * [zigZagPatternTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/strings/zigZagPattern/zigZagPatternTest.java) + * [ZigZagPatternTest](https://github.com/TheAlgorithms/Java/blob/master/src/test/java/com/thealgorithms/strings/zigZagPattern/ZigZagPatternTest.java) diff --git a/checkstyle.xml b/checkstyle.xml index 4078ffbb..cb4ee546 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -116,7 +116,7 @@ - + diff --git a/pmd-exclude.properties b/pmd-exclude.properties index 40086399..eb199da3 100644 --- a/pmd-exclude.properties +++ b/pmd-exclude.properties @@ -10,7 +10,7 @@ com.thealgorithms.conversions.HexToOct=UselessParentheses com.thealgorithms.conversions.IntegerToRoman=UnnecessaryFullyQualifiedName com.thealgorithms.datastructures.crdt.LWWElementSet=UselessParentheses com.thealgorithms.datastructures.crdt.Pair=UnusedPrivateField -com.thealgorithms.datastructures.graphs.A_Star=UselessParentheses +com.thealgorithms.datastructures.graphs.AStar=UselessParentheses com.thealgorithms.datastructures.graphs.AdjacencyMatrixGraph=CollapsibleIfStatements,UnnecessaryFullyQualifiedName,UselessParentheses com.thealgorithms.datastructures.graphs.BipartiteGrapfDFS=CollapsibleIfStatements com.thealgorithms.datastructures.graphs.Kruskal=UselessParentheses diff --git a/src/main/java/com/thealgorithms/datastructures/graphs/A_Star.java b/src/main/java/com/thealgorithms/datastructures/graphs/AStar.java similarity index 99% rename from src/main/java/com/thealgorithms/datastructures/graphs/A_Star.java rename to src/main/java/com/thealgorithms/datastructures/graphs/AStar.java index b1af21eb..54fb5fba 100644 --- a/src/main/java/com/thealgorithms/datastructures/graphs/A_Star.java +++ b/src/main/java/com/thealgorithms/datastructures/graphs/AStar.java @@ -9,8 +9,8 @@ import java.util.Comparator; import java.util.List; import java.util.PriorityQueue; -public final class A_Star { - private A_Star() { +public final class AStar { + private AStar() { } private static class Graph { diff --git a/src/main/java/com/thealgorithms/datastructures/graphs/DIJSKSTRAS_ALGORITHM.java b/src/main/java/com/thealgorithms/datastructures/graphs/DIJSKSTRAS_ALGORITHM.java index 8503aa48..419da4a9 100644 --- a/src/main/java/com/thealgorithms/datastructures/graphs/DIJSKSTRAS_ALGORITHM.java +++ b/src/main/java/com/thealgorithms/datastructures/graphs/DIJSKSTRAS_ALGORITHM.java @@ -4,7 +4,7 @@ for better understanding */ package com.thealgorithms.datastructures.graphs; -class dijkstras { +class Dijkstras { int k = 9; @@ -67,7 +67,7 @@ class dijkstras { {8, 11, 0, 0, 0, 0, 1, 0, 7}, {0, 0, 2, 0, 0, 0, 6, 7, 0}, }; - dijkstras t = new dijkstras(); + Dijkstras t = new Dijkstras(); t.dijkstra(graph, 0); } // main } // djikstras diff --git a/src/main/java/com/thealgorithms/datastructures/lists/Merge_K_SortedLinkedlist.java b/src/main/java/com/thealgorithms/datastructures/lists/MergeKSortedLinkedlist.java similarity index 96% rename from src/main/java/com/thealgorithms/datastructures/lists/Merge_K_SortedLinkedlist.java rename to src/main/java/com/thealgorithms/datastructures/lists/MergeKSortedLinkedlist.java index a714eda1..ece17890 100644 --- a/src/main/java/com/thealgorithms/datastructures/lists/Merge_K_SortedLinkedlist.java +++ b/src/main/java/com/thealgorithms/datastructures/lists/MergeKSortedLinkedlist.java @@ -7,7 +7,7 @@ import java.util.PriorityQueue; /** * @author Arun Pandey (https://github.com/pandeyarun709) */ -public class Merge_K_SortedLinkedlist { +public class MergeKSortedLinkedlist { /** * This function merge K sorted LinkedList diff --git a/src/main/java/com/thealgorithms/datastructures/lists/README.md b/src/main/java/com/thealgorithms/datastructures/lists/README.md index cfb8221a..ea389c04 100644 --- a/src/main/java/com/thealgorithms/datastructures/lists/README.md +++ b/src/main/java/com/thealgorithms/datastructures/lists/README.md @@ -27,6 +27,6 @@ The `next` variable points to the next node in the data structure and value stor 3. `CountSinglyLinkedListRecursion.java`: Recursively counts the size of a list. 4. `CreateAndDetectLoop.java` : Create and detect a loop in a linked list. 5. `DoublyLinkedList.java` : A modification of singly linked list which has a `prev` pointer to point to the previous node. -6. `Merge_K_SortedLinkedlist.java` : Merges K sorted linked list with mergesort (mergesort is also the most efficient sorting algorithm for linked list). +6. `MergeKSortedLinkedlist.java` : Merges K sorted linked list with mergesort (mergesort is also the most efficient sorting algorithm for linked list). 7. `RandomNode.java` : Selects a random node from given linked list and diplays it. 8. `SkipList.java` : Data Structure used for storing a sorted list of elements with help of a Linked list hierarchy that connects to subsequences of elements. diff --git a/src/main/java/com/thealgorithms/misc/matrixTranspose.java b/src/main/java/com/thealgorithms/misc/MatrixTranspose.java similarity index 96% rename from src/main/java/com/thealgorithms/misc/matrixTranspose.java rename to src/main/java/com/thealgorithms/misc/MatrixTranspose.java index 40634f18..153cf4e9 100644 --- a/src/main/java/com/thealgorithms/misc/matrixTranspose.java +++ b/src/main/java/com/thealgorithms/misc/MatrixTranspose.java @@ -18,8 +18,8 @@ import java.util.Scanner; * @version 11.0.9 * @since 2014-03-31 */ -public final class matrixTranspose { - private matrixTranspose() { +public final class MatrixTranspose { + private MatrixTranspose() { } public static void main(String[] args) { diff --git a/src/main/java/com/thealgorithms/others/countSetBits.java b/src/main/java/com/thealgorithms/others/CountSetBits.java similarity index 95% rename from src/main/java/com/thealgorithms/others/countSetBits.java rename to src/main/java/com/thealgorithms/others/CountSetBits.java index 04e0d6f6..b26f745d 100644 --- a/src/main/java/com/thealgorithms/others/countSetBits.java +++ b/src/main/java/com/thealgorithms/others/CountSetBits.java @@ -1,6 +1,6 @@ package com.thealgorithms.others; -public class countSetBits { +public class CountSetBits { /** * The below algorithm is called as Brian Kernighan's algorithm @@ -40,7 +40,7 @@ public class countSetBits { * @param num takes Long number whose number of set bit is to be found * @return the count of set bits in the binary equivalent */ - public long countsetBits(long num) { + public long countSetBits(long num) { long cnt = 0; while (num > 0) { cnt++; diff --git a/src/main/java/com/thealgorithms/others/RotateMatrixBy90Degrees.java b/src/main/java/com/thealgorithms/others/RotateMatrixBy90Degrees.java index 2ea3de81..3930ca3e 100644 --- a/src/main/java/com/thealgorithms/others/RotateMatrixBy90Degrees.java +++ b/src/main/java/com/thealgorithms/others/RotateMatrixBy90Degrees.java @@ -6,8 +6,8 @@ package com.thealgorithms.others; */ import java.util.Scanner; -final class Rotate_by_90_degrees { - private Rotate_by_90_degrees() { +final class RotateMatrixBy90Degrees { + private RotateMatrixBy90Degrees() { } public static void main(String[] args) { diff --git a/src/main/java/com/thealgorithms/searches/sortOrderAgnosticBinarySearch.java b/src/main/java/com/thealgorithms/searches/SortOrderAgnosticBinarySearch.java similarity index 90% rename from src/main/java/com/thealgorithms/searches/sortOrderAgnosticBinarySearch.java rename to src/main/java/com/thealgorithms/searches/SortOrderAgnosticBinarySearch.java index acb9fb5c..6a2a46c2 100644 --- a/src/main/java/com/thealgorithms/searches/sortOrderAgnosticBinarySearch.java +++ b/src/main/java/com/thealgorithms/searches/SortOrderAgnosticBinarySearch.java @@ -1,6 +1,6 @@ package com.thealgorithms.searches; -public final class sortOrderAgnosticBinarySearch { - private sortOrderAgnosticBinarySearch() { +public final class SortOrderAgnosticBinarySearch { + private SortOrderAgnosticBinarySearch() { } public static int find(int[] arr, int key) { int start = 0; diff --git a/src/main/java/com/thealgorithms/strings/longestNonRepeativeSubstring.java b/src/main/java/com/thealgorithms/strings/LongestNonRepeativeSubstring.java similarity index 93% rename from src/main/java/com/thealgorithms/strings/longestNonRepeativeSubstring.java rename to src/main/java/com/thealgorithms/strings/LongestNonRepeativeSubstring.java index 99154542..140e668f 100644 --- a/src/main/java/com/thealgorithms/strings/longestNonRepeativeSubstring.java +++ b/src/main/java/com/thealgorithms/strings/LongestNonRepeativeSubstring.java @@ -2,8 +2,8 @@ package com.thealgorithms.strings; import java.util.HashMap; -final class longestNonRepeativeSubstring { - private longestNonRepeativeSubstring() { +final class LongestNonRepeativeSubstring { + private LongestNonRepeativeSubstring() { } public static int lengthOfLongestSubstring(String s) { diff --git a/src/main/java/com/thealgorithms/strings/zigZagPattern/zigZagPattern.java b/src/main/java/com/thealgorithms/strings/zigZagPattern/ZigZagPattern.java similarity index 95% rename from src/main/java/com/thealgorithms/strings/zigZagPattern/zigZagPattern.java rename to src/main/java/com/thealgorithms/strings/zigZagPattern/ZigZagPattern.java index 2dfcf390..3337f6ee 100644 --- a/src/main/java/com/thealgorithms/strings/zigZagPattern/zigZagPattern.java +++ b/src/main/java/com/thealgorithms/strings/zigZagPattern/ZigZagPattern.java @@ -1,7 +1,7 @@ package com.thealgorithms.strings.zigZagPattern; -final class zigZagPattern { - private zigZagPattern() { +final class ZigZagPattern { + private ZigZagPattern() { } public static String encode(String s, int numRows) { diff --git a/src/test/java/com/thealgorithms/dynamicprogramming/climbStairsTest.java b/src/test/java/com/thealgorithms/dynamicprogramming/ClimbStairsTest.java similarity index 95% rename from src/test/java/com/thealgorithms/dynamicprogramming/climbStairsTest.java rename to src/test/java/com/thealgorithms/dynamicprogramming/ClimbStairsTest.java index 7df3127e..1f2de4a1 100644 --- a/src/test/java/com/thealgorithms/dynamicprogramming/climbStairsTest.java +++ b/src/test/java/com/thealgorithms/dynamicprogramming/ClimbStairsTest.java @@ -4,7 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; -public class climbStairsTest { +public class ClimbStairsTest { @Test void climbStairsTestForTwo() { diff --git a/src/test/java/com/thealgorithms/others/CountSetBitsTest.java b/src/test/java/com/thealgorithms/others/CountSetBitsTest.java new file mode 100644 index 00000000..ab34c6ba --- /dev/null +++ b/src/test/java/com/thealgorithms/others/CountSetBitsTest.java @@ -0,0 +1,17 @@ +package com.thealgorithms.others; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +public class CountSetBitsTest { + + @Test + void testSetBits() { + CountSetBits csb = new CountSetBits(); + assertEquals(1L, csb.countSetBits(16)); + assertEquals(4, csb.countSetBits(15)); + assertEquals(5, csb.countSetBits(10000)); + assertEquals(5, csb.countSetBits(31)); + } +} diff --git a/src/test/java/com/thealgorithms/others/countSetBitsTest.java b/src/test/java/com/thealgorithms/others/countSetBitsTest.java deleted file mode 100644 index 1429aac8..00000000 --- a/src/test/java/com/thealgorithms/others/countSetBitsTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.thealgorithms.others; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; - -public class countSetBitsTest { - - @Test - void testSetBits() { - countSetBits csb = new countSetBits(); - assertEquals(1L, csb.countsetBits(16)); - assertEquals(4, csb.countsetBits(15)); - assertEquals(5, csb.countsetBits(10000)); - assertEquals(5, csb.countsetBits(31)); - } -} diff --git a/src/test/java/com/thealgorithms/searches/sortOrderAgnosticBinarySearchTest.java b/src/test/java/com/thealgorithms/searches/SortOrderAgnosticBinarySearchTest.java similarity index 75% rename from src/test/java/com/thealgorithms/searches/sortOrderAgnosticBinarySearchTest.java rename to src/test/java/com/thealgorithms/searches/SortOrderAgnosticBinarySearchTest.java index 04ed00ae..e2917733 100644 --- a/src/test/java/com/thealgorithms/searches/sortOrderAgnosticBinarySearchTest.java +++ b/src/test/java/com/thealgorithms/searches/SortOrderAgnosticBinarySearchTest.java @@ -4,13 +4,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; -public class sortOrderAgnosticBinarySearchTest { +public class SortOrderAgnosticBinarySearchTest { @Test public void testAscending() { int[] arr = {1, 2, 3, 4, 5}; // for ascending order. int target = 2; - int ans = sortOrderAgnosticBinarySearch.find(arr, target); + int ans = SortOrderAgnosticBinarySearch.find(arr, target); int excepted = 1; assertEquals(excepted, ans); } @@ -19,7 +19,7 @@ public class sortOrderAgnosticBinarySearchTest { public void testDescending() { int[] arr = {5, 4, 3, 2, 1}; // for descending order. int target = 2; - int ans = sortOrderAgnosticBinarySearch.find(arr, target); + int ans = SortOrderAgnosticBinarySearch.find(arr, target); int excepted = 3; assertEquals(excepted, ans); } diff --git a/src/test/java/com/thealgorithms/strings/longestNonRepeativeSubstringTest.java b/src/test/java/com/thealgorithms/strings/LongestNonRepeativeSubstringTest.java similarity index 64% rename from src/test/java/com/thealgorithms/strings/longestNonRepeativeSubstringTest.java rename to src/test/java/com/thealgorithms/strings/LongestNonRepeativeSubstringTest.java index 2dce8cf3..4bd5ac99 100644 --- a/src/test/java/com/thealgorithms/strings/longestNonRepeativeSubstringTest.java +++ b/src/test/java/com/thealgorithms/strings/LongestNonRepeativeSubstringTest.java @@ -3,13 +3,13 @@ package com.thealgorithms.strings; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class longestNonRepeativeSubstringTest { +public class LongestNonRepeativeSubstringTest { @Test public void palindrome() { String input1 = "HelloWorld"; String input2 = "javaIsAProgrammingLanguage"; - Assertions.assertEquals(longestNonRepeativeSubstring.lengthOfLongestSubstring(input1), 5); - Assertions.assertEquals(longestNonRepeativeSubstring.lengthOfLongestSubstring(input2), 9); + Assertions.assertEquals(LongestNonRepeativeSubstring.lengthOfLongestSubstring(input1), 5); + Assertions.assertEquals(LongestNonRepeativeSubstring.lengthOfLongestSubstring(input2), 9); } } diff --git a/src/test/java/com/thealgorithms/strings/zigZagPattern/zigZagPatternTest.java b/src/test/java/com/thealgorithms/strings/zigZagPattern/ZigZagPatternTest.java similarity index 67% rename from src/test/java/com/thealgorithms/strings/zigZagPattern/zigZagPatternTest.java rename to src/test/java/com/thealgorithms/strings/zigZagPattern/ZigZagPatternTest.java index 02904ddc..518bfab8 100644 --- a/src/test/java/com/thealgorithms/strings/zigZagPattern/zigZagPatternTest.java +++ b/src/test/java/com/thealgorithms/strings/zigZagPattern/ZigZagPatternTest.java @@ -3,13 +3,13 @@ package com.thealgorithms.strings.zigZagPattern; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class zigZagPatternTest { +public class ZigZagPatternTest { @Test public void palindrome() { String input1 = "HelloWorldFromJava"; String input2 = "javaIsAProgrammingLanguage"; - Assertions.assertEquals(zigZagPattern.encode(input1, 4), "HooeWrrmalolFJvlda"); - Assertions.assertEquals(zigZagPattern.encode(input2, 4), "jAaLgasPrmgaaevIrgmnnuaoig"); + Assertions.assertEquals(ZigZagPattern.encode(input1, 4), "HooeWrrmalolFJvlda"); + Assertions.assertEquals(ZigZagPattern.encode(input2, 4), "jAaLgasPrmgaaevIrgmnnuaoig"); } }