Genetic algorithms follow principles of evolution and natural selection to find optimal or near-optimal solutions to problems. The document describes using a genetic algorithm to solve the knapsack problem, where the goal is to fill a knapsack with items of maximum total value without exceeding the knapsack's weight limit. The algorithm encodes potential solutions as chromosomes, generates an initial random population, evaluates their fitness, selects parents for reproduction, performs crossover and mutation to generate new offspring, and iterates this process until finding an optimal or near-optimal solution.