In this talk, we analyze adaptive mesh-refinement algorithms for finite element and boundary element discretizations of partial differential equations (PDEs). We introduce the concept of a posteriori error estimation and its usefulness to minimize both the approximation error and the computational costs. This leads to the concept of rate optimality as well as optimal complexity of adaptive algorithms. We discuss the state of the art of the theory as well as our own contributions. This includes the identification of abstract (problem independent) assumptions which are sufficient and sometimes even necessary to prove rate optimality of the given algorithm. This abstract approach allows to treat interesting problems involving non-linear, non-symmetric, and even non-local operators.