BruteForce Algorithms

Bruteforce algorithms generate every possible answer and select only the valid ones.

For example, completing a Canvas Quiz by trying all possible answers until earning full points would be considered a bruteforce approach. (Although we do limit the number of attempts to three!)

Another example would be pick all subsets of numbers and see which add up to a given sum.

Finally, imagine you are trying to break into your friend’s iPhone by guessing the fourdigit passcode. You could systematically try all the passcodes between 0000 and 9999. Unfortunately, that would take an extremely long time if you have to tap on each number with your finger to type the passcode (unless you have something like this).

Often, brute force algorithms require exponential time.

We can usually improve a bruteforce algorithm with heuristics and optimizations, but some algorithms can only be solved by bruteforce, unfortunately.