Efficient problem solving with standard algorithms

It’s easy to forget that complex algorithms can be implemented by combining algorithms from the standard library. Maybe because of our old habit of trying to solve problems by hand and immediately starting to handcraft for-loops and working through the problem using an imperative approach. If this sounds familiar, we recommend getting to know the standard algorithms well enough so that by starting considering them as the first choice.

We promote the use of standard library algorithms over raw for-loops for a number of reasons:

  • Standard algorithms deliver performance. Even though some of the algorithms in the standard library may seem trivial, they are often optimally designed in ways that are not obvious at first glance.
  • Standard algorithms provide safety. Even simpler algorithms may have corner cases, which are easy to overlook.
  • Standard algorithms are future-proof; a more suitable algorithm can replace a given algorithm if we want to take advantage of SIMD extensions, parallelism, or even the GPU.
  • Standard algorithms are thoroughly documented.

Get hands-on with 1200+ tech skills courses.