Reconfigurability, self-reproduction and self-healing are unique behaviors found in the field of modular robotics. These tasks require docking or coupling and reorganizing of modules to form different configurations according to the task requirements. For successful task achievement, efficient information sharing between the modules, better perception of configuration and well-structured motion sequence or docking are very important. In a scenario where sharing resources between different configurations is a priority, it is crucial to have a well-defined, energy-efficient, task-specific and effective strategy of operation. This paper presents a method to (1) discover the topology of a given structure by a master module in a recursive manner, (2) share the information with another master module to compare the utility of current or future configurations and (3) make a successful docking attachment. These all use automata theory to minimize calculation overhead. The first two methods were tested in simulation for an arbitrary ModRED II (Modular Robot for Exploration and Discovery) configuration with nine modules that uses serial communication between modules, and the third was validated in hardware.