-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Rearranges items so that all items in the [left, k] are the smallest. | ||
* The k-th element will have the (k - left + 1)-th smallest value in [left, right]. | ||
* | ||
* @param arr the array to partially sort (in place) | ||
* @param k middle index for partial sorting (as defined above) | ||
* @param left left index of the range to sort (0 by default) | ||
* @param right right index (last index of the array by default) | ||
* @param compare compare function | ||
*/ | ||
export default function quickselect<T>( | ||
arr: T[], | ||
k: number, | ||
left?: number, | ||
right?: number, | ||
compare?: (x: T, y: T) => number | ||
): void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters