In this example, each generation has a population of 12 with each person being represented by a bitstring. Fitness value is determined by the number of '1's in a bitstring. The top 4 individuals are then used to generate the 12 people in the next generation.
The bitstrings in the first generation are randomly generated such that each bit has a 10% chance of being a '1'. The mutation rate is 5%. Just like in real life, mutations allow the population to increase its average fitness value over the course of many generations. The Genetic Algorithm sacrifices the best value in hopes of achieving a better value in the next generation; however, this is not guaranteed.

Bitstring Length

Number of Generations