~/talk

Evolution of a Median Algorithm in C++

Talkat CppCon 2023 · on Thursday, 2023-10-05· at 15:50· Adams, 6700 North Gaylord Rockies Boulevard· [databases]
slides:none on file

Starts from the simple sort-and-index approach and evolves into a templated, ranges-aware median() that uses nth_element and max_element and handles overflow with midpoint. An experiment on 10 million integers shows runtime drop from about 972 ms to 89 ms. The API moves from returning values to returning iterator pairs, then to a tidy median result class that hides details; it runs in average linear time but crucially permutes the container and considers execution policies and concepts.

AI-written summary · about

  1. 0:00Median algorithm challenge
  2. 1:48Standard library lacks median
  3. 3:55Standardize generic median
  4. 5:23Empty containers and edge cases
  5. 6:49Even-sized range median
  6. 8:15Avoiding integer overflow
  7. 9:18Performance bottleneck sort
  8. 10:23Linear-time median nth_element
  9. 11:46Fixing nth_element usage
  10. 12:50Second middle element
  11. 13:34Benchmarking improvements
  12. 14:37Generic for any container
  13. 15:44Returning iterators
  14. 17:53Range-based generic algorithm
  15. 18:59Execution policies C++20
  16. 20:24Constraints with Concepts
  17. 21:28Median result class
  18. 23:36Key takeaways generic median
  19. 24:37Performance trade-offs
  20. 25:39Standardization next steps
  21. 27:05Community call to action
  22. 28:28Closing remarks Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.