Likely through colony behavior. Single cellular organisms divided by mitosis just to reproduce and sometimes there would be some sort of variation to one or more of those organisms that offered a net benefit to the colony. These colonies were more successful than other colonies and evolved to produce a certain percentage of those single cellular organisms which over time developed into specialized cells of a multicellular organism.
Latest Answers