---
title: "Short note: Genetic algorithm"
subject: "Data Mining"
chapter: 3
key: "semester_7/data_mining:genetic-algorithm-note"
source: https://www.bctengineer.com/q/semester_7/data_mining/genetic-algorithm-note
site: BCT Engineering
---

# Short note: Genetic algorithm

Data Mining · Chapter 3: Classification

- Asked in: 2066 Bhadra, 3 marks; year not given, 3 marks
- Video: [Lec-38: Genetic Algorithm in Artificial Intelligence | Simplest Explanation with real life examples](https://www.youtube.com/watch?v=96-u9s6D16k) — Gate Smashers
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/data_mining/genetic-algorithm-note
- Whole chapter: https://www.bctengineer.com/md/semester_7/data_mining/chapter-3

## Question

Write a short note on Genetic Algorithm.

## Short answer

A genetic algorithm is a search and optimisation method inspired by natural selection. A population of encoded solutions evolves through fitness evaluation, selection, crossover and mutation until a stopping condition. It searches many points at once and avoids local optima, but can be slow and parameter-dependent.

## Answer

A **Genetic Algorithm (GA)** is a search and optimisation technique based on natural selection and genetics ("survival of the fittest"). In data mining it is used for classification-rule discovery, feature selection, clustering and tuning of neural networks.

#### Basic idea
A population of candidate solutions evolves over generations. Each solution is encoded as a **chromosome**, often a bit string (e.g. the rule `IF A1 AND NOT A2 THEN C2` is encoded as `1 0 0`).

#### Steps
1. Create an initial **population** of random chromosomes.
2. Compute the **fitness** of each (e.g. classification accuracy of the rule).
3. **Selection**: choose fitter chromosomes as parents.
4. **Crossover**: exchange parts of two parents to make offspring.
5. **Mutation**: randomly flip some bits with small probability to keep diversity.
6. Form the new population; repeat from step 2 until a stopping condition (required fitness or maximum generations) is met.

```text
Population -> Fitness -> Selection -> Crossover
     ^                                  |
     +------- Mutation <----------------+
```

#### Features
It searches many points at once, so it is less likely to get stuck in local optima, and it needs no gradient. However, it can be slow, and the result depends on the encoding and the parameters.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. How is a solution represented in a genetic algorithm?
   A. As a decision tree only
   B. As a single real number only
   C. As a chromosome, often a bit string
   D. As a distance matrix
   Answer: C. Candidate solutions are encoded as chromosomes. (Key point: Chromosome)

2. What is the role of the fitness function and selection?
   A. Fitness randomly flips bits
   B. Selection removes the fittest chromosomes
   C. Fitness creates the initial population
   D. Fitness measures each chromosome's quality, and fitter ones are chosen as parents
   Answer: D. Fitter chromosomes get to reproduce. (Key point: Fitness and selection)

3. Why is mutation applied with small probability?
   A. To keep diversity by randomly flipping bits without making the search random
   B. To combine two parents
   C. To compute fitness
   D. To stop the algorithm
   Answer: A. Mutation maintains diversity. (Key point: Mutation)

4. When does a GA stop?
   A. After exactly one generation
   B. When required fitness or maximum generations is reached
   C. When all bits are mutated
   D. When the population is empty
   Answer: B. The steps repeat until a stopping condition is met. (Key point: Stopping)

## Related in Data Mining

- [Crossover and mutation in GA](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Acrossover-mutation-ga) — Data Mining, chapter 3

## Related in other subjects

- [Genetic algorithm and operators](https://www.bctengineer.com/question.md?key=semester_6%2Fartificial_intelligence%3Agenetic-algorithm-operators) — Artificial Intelligence, chapter 6, asked 4×
