Skip to content

Commit f40ad89

Browse files
committed
Randomize Quick Sort Addition
1 parent 81daef5 commit f40ad89

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/main/java/com/thealgorithms/randomized/RandomizedQuickSort.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@
33
/**
44
* This class implements the Randomized QuickSort algorithm.
55
* It selects a pivot randomly to improve performance on sorted or nearly sorted data.
6+
* @author Vibhu Khera
67
*/
78
public class RandomizedQuickSort {
89

10+
private RandomizedQuickSort() {
11+
throw new UnsupportedOperationException("Utility class");
12+
}
13+
914
/**
1015
* Sorts the array using the randomized quicksort algorithm.
1116
*

src/test/java/com/thealgorithms/randomized/RandomizedQuickSortTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class RandomizedQuickSortTest {
1313
* Tests sorting of an array with multiple elements, including duplicates.
1414
*/
1515
@Test
16-
public void testRandomizedQuickSort_multipleElements() {
16+
public void testRandomizedQuickSortMultipleElements() {
1717
int[] arr = {3, 6, 8, 10, 1, 2, 1};
1818
int[] expected = {1, 1, 2, 3, 6, 8, 10};
1919
RandomizedQuickSort.randomizedQuickSort(arr, 0, arr.length - 1);
@@ -24,7 +24,7 @@ public void testRandomizedQuickSort_multipleElements() {
2424
* Tests sorting of an empty array.
2525
*/
2626
@Test
27-
public void testRandomizedQuickSort_emptyArray() {
27+
public void testRandomizedQuickSortEmptyArray() {
2828
int[] arr = {};
2929
int[] expected = {};
3030
RandomizedQuickSort.randomizedQuickSort(arr, 0, arr.length - 1);
@@ -35,7 +35,7 @@ public void testRandomizedQuickSort_emptyArray() {
3535
* Tests sorting of an array with a single element.
3636
*/
3737
@Test
38-
public void testRandomizedQuickSort_singleElement() {
38+
public void testRandomizedQuickSortSingleElement() {
3939
int[] arr = {5};
4040
int[] expected = {5};
4141
RandomizedQuickSort.randomizedQuickSort(arr, 0, arr.length - 1);

0 commit comments

Comments
 (0)