Algorithm Intuition (part 2 of 2)
summary
Covers 11 numeric STL algorithms (calls out 111 algorithms total) and shows concrete rewrites: use transform_reduce to compute adjacent differences without extra memory, use inclusive_scan (partial_sum) to answer range-sum and rain-trapping queries, and use an adjacent_transform pattern (zip with tail) to find min gaps or longest equal runs. Points out real pitfalls: a naive fold breaks parallelism (non‑associative lambda), RMS examples miss dividing by n, and Ben Dean’s result of implementing 77 of 90 pre‑C++17 algorithms from accumulate. Uses C++17/20 features and range examples; code and slides on GitHub.
AI-written summary · about
chapters (12)
- 0:00Introduction to algorithm intuition
- 1:58Summary of part one
- 4:46Numeric header algorithms overview
- 9:00Revisiting adjacent difference
- 12:14Transform reduce favorite algorithm
- 23:51Partial sum and inclusive scan
- 34:16Algorithm intuition table
- 37:18Solving Codeforces problem
- 44:16Adjacent find and adjacent transform
- 51:42Transform inclusive scan
- 53:26STL algorithm composability issues
- 56:14Conclusion and Q&A
related talks
56mBeginners Guide to C++'s Best Kept Secret -- std::algorithm
01h 35mThe Twin Algorithms
46mC++ Fundamentals - Algorithms
01h 25mNew Algorithms in C++23
01h 31mSTL Algorithms – How to Use Them and How to Write Your Own
01h 23mAlex Stepanov, Generic Programming in Cpp, and the STL
01h 25mComparing 'Classic C++' and 'Modern C++' Ways to Solve Programming Tasks
57m“The C++17 Parallel Algorithms Library and Beyond"
