Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita1adc15

Browse files
authored
Update k-th.md
#1215 basics solved.
1 parent46caa5b commita1adc15

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎src/sequences/k-th.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ T order_statistics (std::vector<T> a, unsigned n, unsigned k)
6868
6969
## Notes
7070
* The randomized algorithm above is named [quickselect](https://en.wikipedia.org/wiki/Quickselect). You should do random shuffle on $A$ before calling it or use a random element as a barrier for it to run properly. There are also deterministic algorithms that solve the specified problem in linear time, such as [median of medians](https://en.wikipedia.org/wiki/Median_of_medians).
71-
*A deterministic linear solution is implemented in C++ standard library as[std::nth_element](https://en.cppreference.com/w/cpp/algorithm/nth_element).
71+
* [std::nth_element](https://en.cppreference.com/w/cpp/algorithm/nth_element) solves this in C++ but gcc's implementation runs in worst case $O(n \log n )$ time.
7272
* Finding $K$ smallest elements can be reduced to finding $K$-th element with a linear overhead, as they're exactly the elements that are smaller than $K$-th.
7373
7474
## Practice Problems

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp