  Algorithmic debugging is a semi-automatic debugging technique that allows the
programmer to precisely identify the location of bugs without the need to
inspect the source code. The technique has been successfully adapted to all
paradigms and mature implementations have been released for languages such as
Haskell, Prolog or Java. During three decades, the algorithm introduced by
Shapiro and later improved by Hirunkitti has been thought optimal. In this
paper we first show that this algorithm is not optimal, and moreover, in some
situations it is unable to find all possible solutions, thus it is incomplete.
Then, we present a new version of the algorithm that is proven optimal, and we
introduce some equations that allow the algorithm to identify all optimal
solutions.
