-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved efficency of median calculation in the even case.
This relies on the fact that, after nth_element() is called, all elements that are not greater than the n-th element have been moved before the n-th element. Thus, to find the (n-1)-th element, we simply have to take the maximum of the elements before the n-th element with max_element(), rather than calling nth_element() again. The former is guaranteed linear and much simpler than the latter.
- Loading branch information
Showing
2 changed files
with
202 additions
and
72 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
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