Last Updated: May 22, 2026
The <algorithm> header is split into two broad families. The first family contains the non-modifying algorithms: functions that read a range, ask a question about it, or locate something inside it, without changing any element. They form the backbone of "search and check" code in C++: finding a product by id, counting in-stock items, verifying every order has a valid status, comparing two carts for equality. This chapter covers the most useful ones, the iterator return values they share, and the cost model that makes them O(n) but rarely surprising.