8 Ad Hoc Problems and Advanced Techniques

 
A coin with a cartoon of a cow and corn Description automatically generated with low confidence

This chapter covers

  • Approaching problems that do not fall into any of the previous categories.
  • Solving problems using the forward-backward technique.
  • Applying the coordinate compression principle to reduce time and space complexities.
  • Using and manipulating tree structures.
  • Simplifying programs using dictionaries and maps.

Ad hoc problems, also called logic problems or general problems, are problems that do not fall into any of the categories already discussed: modeling, searching, or geometry. Although there’s no single approach that will always work to solve these problems, there are a handful of techniques that can help you solve many of these problems, or at least simplify them.

8.1 Forward and Backward

8.2 Significant Events

8.3 Trees

8.4 Dictionaries and Dynamic Arrays

8.5 Summary