Example of using the genetic algorithm.
1) N-Bits: Given a set of 5 genes, each gene can hold one of the binary values 0 and 1. The fitness value is calculated as the number of 1s present in the genome. If there are five 1s, then it is having maximum fitness. If there are no 1s, then it has the minimum fitness.
This genetic algorithm tries to maximize the fitness function to provide a population consisting of the fittest individual, i.e. individuals with five 1s. Note: In this example, after crossover and mutation, the least fit individual is replaced from the new fittest offspring.
2) 8-Queens Puzzle: The problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other.