Preview lessons, content and tests

Computer Science & Programming solved. All in one platform.

1. To trial the platform and take tests, please take a few seconds to SIGN UP and SET UP FREE.
2. Searching for something specific? See our text overview of all tests. Scroll right for levels, and lists.

Join 36000+ teachers and students using TTIO.

Genetics and Algorithms

genetic algorithm is a search heuristic that is inspired by Charles Darwin's theory of natural evolution. This algorithm reflects the process of natural selection where the fittest individuals are selected for reproduction in order to produce offspring of the next generation.


Optimization is the process of making something better. In any process, we have a set of inputs and a set of outputs as shown in the following figure.Optimization refers to finding the values of inputs in such a way that we get the “best” output values.

File:CPT Hardware-InputOutput.svg - Wikimedia Commons

Suggested Video

Tutorial - Create your own GA (Genetic Algorithm)

First: Setting the scene - the knapsack problem

Additional Information

They are commonly used to generate high-quality solutions for optimization problems and search problems.

Genetic algorithms simulate the process of natural selection which means those species who can adapt to changes in their environment are able to survive and reproduce and go to next generation. In simple words, they simulate “survival of the fittest” among individual of consecutive generation for solving a problem. 

How it works

Each generation consist of a population of individuals and each individual represents a point in search space and possible solution. Each individual is represented as a string of character/integer/float/bits. This string is analogous to the Chromosome.