Brute-force Algorithms

A brute-force algorithm is a straightforward and exhaustive problem-solving approach that systematically explores all possible solutions or combinations to a problem. It does not rely on advanced strategies or optimizations and instead relies on sheer computational power to find a solution. The term “brute force” implies that the algorithm forcefully checks every possible option without taking shortcuts or using heuristics to prune the search space.

Characteristics

  • Exhaustive

  • Naive: no optimization, no heuristics

  • Simple: easy to implement

  • Inefficient: exponential time complexity

  • Deterministic: always produces the same output for a given input

Application Domain

Brute-force algorithms are used when the problem size is small enough to be practical, especially when no other more efficient solutions are available. It is also suitable for problems that require all possible solutions to be examined.

  • Combination and permutation

Implementation

  • Recursive

  • Iterative