Reliable and safe operation of a nuclear power plant or any other complex network of flow-connected subunits requires prompt detection and location of failed subunits. An algorithm is described, which performs (in many cases) unambiguous automatic location of single or multiple failures. Types of failures that cannot be located unambiguously are characterized. The algorithm can be applied to networks with a serial array of subunits, with converging or branching nodes or with feedback. An optimal structure of the algorithm is identified that allows the maximal failure locating capability with a minimum of logical or arithmetical manipulation. This is important especially for application to large systems. The dynamic behavior of the algorithm is examined for a simple system.