In developing brain, axons and dendrites are capable of connecting to each other with high precision. Imaging of axonal and dendritic dynamics in vivo shows that the majority of axonal and dendritic branches are formed ‘in error’, only to be retracted later. The functional significance of the overproduction of branches is not clear. Here we show that branching of both axons and dendrites can accelerate finding appropriate synaptic targets during the development of neuronal circuitry. We suggest that branching rules implemented by axons and dendrites minimize the number of erroneous branches. We find that optimal branching rules are different for axons and dendrites in agreement with experimentally observed branch dynamics. Thus, our studies suggest that the developing neural system employs a set of sophisticated computational strategies that facilitate the formation of required circuitry in the fastest and most frugal way