Skip to content

Commit 282c457

Browse files
committed
updated QuickSelect.ts #7
1 parent ff88b6f commit 282c457

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Data-structures/QuickSelect.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22
* [QuickSelect](https://www.geeksforgeeks.org/quickselect-algorithm/) is an algorithm to find the kth smallest number
33
*
44
* Notes:
5-
* - QuickSelect is related to QuickSort, thus has optimal best and average case (O(n)) but unlikely poor worst case (O(n^2))
6-
* - This implementation uses randomly selected pivots for better performance
5+
* - QuickSelect is related to QuickSort, thus has optimal best and average case O(n) but unlikely poor worst case O(n^2)
76
* ----
8-
* @complexity : O(n) (on average )
9-
* @complexity : O(n^2) (worst case)
7+
* @complexity O(n) (on average)
8+
* @complexity O(n^2) (worst case)
109
* ----
1110
* @param items array
1211
* @flow
1312
*/
1413

1514
const QuickSelect = (items: Array<number>, kth: number): number => {
16-
// eslint-disable-line no-unused-vars
1715
if (kth < 1 || kth > items.length) {
1816
throw new RangeError("Index Out of Bound");
1917
}

0 commit comments

Comments
 (0)