Brute-force Search - Speeding Up Brute-force Searches

Speeding Up Brute-force Searches

One way to speed up a brute-force algorithm is to reduce the search space, that is, the set of candidate solutions, by using heuristics specific to the problem class. For example, in the eight queens problem the challenge is to place eight queens on a standard chessboard so that no queen attacks any other. Since each queen can be placed in any of the 64 squares, in principle there are 648 = 281,474,976,710,656 possibilities to consider. However, because the queens are all alike, and that no two queens can be placed on the same square, the candidates are all possible ways of choosing of a set of 8 squares from the set all 64 squares; which means 64 choose 8 = 64!/56!8! = 4,426,165,368 candidate solutions — about 1/60,000 of the previous estimate. Further, no arrangement with two queens on the same row or the same column can be a solution. Therefore, we can further restrict the set of candidates to those arrangements.

As this example shows, a little bit of analysis will often lead to dramatic reductions in the number of candidate solutions, and may turn an intractable problem into a trivial one.

In some cases, the analysis may reduce the candidates to the set of all valid solutions; that is, it may yield an algorithm that directly enumerates all the desired solutions (or finds one solution, as appropriate), without wasting time with tests and the generation of invalid candidates. For example, for the problem "find all integers between 1 and 1,000,000 that are evenly divisible by 417" a naive brute-force solution would generate all integers in the range, testing each of them for divisibility. However, that problem can be solved much more efficiently by starting with 417 and repeatedly adding 417 until the number exceeds 1,000,000 — which takes only 2398 (= 1,000,000 ÷ 417) steps, and no tests.

Read more about this topic:  Brute-force Search

Famous quotes containing the words speeding up, speeding and/or searches:

    The correct rate of speed in innovating changes in long-standing social customs has not yet been determined by even the most expert of the experts. Personally I am beginning to think there is more danger in lagging than in speeding up cultural change to keep pace with mechanical change.
    Mary Barnett Gilson (1877–?)

    The correct rate of speed in innovating changes in long-standing social customs has not yet been determined by even the most expert of the experts. Personally I am beginning to think there is more danger in lagging than in speeding up cultural change to keep pace with mechanical change.
    Mary Barnett Gilson (1877–?)

    When a person doesn’t understand something, he feels internal discord: however he doesn’t search for that discord in himself, as he should, but searches outside of himself. Thence a war develops with that which he doesn’t understand.
    Anton Pavlovich Chekhov (1860–1904)