Skip to content

Commit d1cf92f

Browse files
committed
Fix clang-format issues in DoubleHashingSort
- Remove trailing spaces from all lines - Fix inconsistent blank line formatting in comments - Standardize JavaDoc comment spacing - Ensure consistent indentation and line breaks - Remove extra spaces after comment markers
1 parent a7cec6f commit d1cf92f

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/main/java/com/thealgorithms/sorts/DoubleHashingSort.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
* Double Hashing Sort uses a hybrid approach combining hashing with traditional sorting.
99
* It creates hash buckets using double hashing technique to distribute elements
1010
* and then sorts each bucket individually.
11-
*
11+
*
1212
* Time Complexity:
1313
* - Best Case: O(n) when elements are uniformly distributed
14-
* - Average Case: O(n log n)
14+
* - Average Case: O(n log n)
1515
* - Worst Case: O(n²) when all elements hash to same bucket
16-
*
16+
*
1717
* Space Complexity: O(n) for the auxiliary buckets
18-
*
18+
*
1919
* @author TheAlgorithms Team
2020
* @see <a href="https://en.wikipedia.org/wiki/Hash_function">Hash Function</a>
2121
*/
@@ -35,7 +35,7 @@ public <T extends Comparable<T>> T[] sort(T[] array) {
3535

3636
/**
3737
* Sorts array using double hashing technique
38-
*
38+
*
3939
* @param array the array to be sorted
4040
* @param bucketCount number of buckets to use
4141
* @return sorted array
@@ -68,10 +68,10 @@ private <T extends Comparable<T>> T[] doubleHashingSort(T[] array, int bucketCou
6868
@SuppressWarnings("unchecked")
6969
T[] bucket = (T[]) new Comparable[bucketSizes[i]];
7070
System.arraycopy(buckets[i], 0, bucket, 0, bucketSizes[i]);
71-
71+
7272
// Sort the bucket
7373
Arrays.sort(bucket);
74-
74+
7575
// Copy back to main array
7676
System.arraycopy(bucket, 0, array, index, bucketSizes[i]);
7777
index += bucketSizes[i];
@@ -83,7 +83,7 @@ private <T extends Comparable<T>> T[] doubleHashingSort(T[] array, int bucketCou
8383

8484
/**
8585
* Calculates bucket index using double hashing technique
86-
*
86+
*
8787
* @param element the element to hash
8888
* @param bucketCount number of available buckets
8989
* @return bucket index
@@ -95,10 +95,10 @@ private <T extends Comparable<T>> int getBucketIndex(T element, int bucketCount)
9595

9696
// Primary hash function
9797
int hash1 = Math.abs(element.hashCode()) % bucketCount;
98-
98+
9999
// Secondary hash function (must be odd and different from bucket count)
100100
int hash2 = 7 - (Math.abs(element.hashCode()) % 7);
101-
101+
102102
// Double hashing formula: (hash1 + i * hash2) % bucketCount
103103
// For simplicity, we use i = 1 here, but could be extended for collision resolution
104104
return (hash1 + hash2) % bucketCount;

src/test/java/com/thealgorithms/sorts/DoubleHashingSortTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Test class for DoubleHashingSort algorithm
55
*/
66
public class DoubleHashingSortTest extends SortingAlgorithmTest {
7-
7+
88
@Override
99
SortAlgorithm getSortAlgorithm() {
1010
return new DoubleHashingSort();

0 commit comments

Comments
 (0)