Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what exactly is the brute force algorithm [closed]

Tags:

algorithm

  1. what exactly is the brute force algorithm? (besides just the approach only)

  2. when a problem can use brute-force approach, and when not to?

  3. What characteristics are there in an algorithm, when the algorithm uses brute force approach?

like image 357
nehemkris Avatar asked Nov 12 '11 06:11

nehemkris


People also ask

What is brute force algorithm explain?

Brute Force Algorithms are exactly what they sound like – straightforward methods of solving a problem that rely on sheer computing power and trying every possibility rather than advanced techniques to improve efficiency. For example, imagine you have a small padlock with 4 digits, each from 0-9.

What is the problem with brute force strategy approach?

The main disadvantage of the brute-force method is that, for many real-world problems, the number of natural candidates is prohibitively large. For instance, if we look for the divisors of a number as described above, the number of candidates tested will be the given number n.

Can brute force find all solutions?

Some of the features of brute force algorithms are: A brute force algorithm is an intuitive, direct, and straightforward technique of problem solving that enumerates all the possible ways or all the possible solutions to a specified problem.

What is the time complexity of the brute force algorithm?

The brute force algorithm requires no preprocessing phase, and a constant extra space in addition to the pattern and the text. During the searching phase the text character comparisons can be done in any order. The time complexity of this searching phase is O(mn) (when searching for am-1b in an for instance).


1 Answers

1 and 3 : Brute force means that you will go through all possible solutions extensively. For example, in a chess game, if you know you can win in two moves, the brute force will go through all possible combination of moves, without taking anything in consideration. So the little pawn in the back that cannot influence the outcome will still be considered.

2 : As you consider everything, the problem quickly goes out of control. Brute force through 15 moves in chess is impossible because of combinatorial explosion (too many situations to consider). However, more clever algorithms that take into account "knowledge about the problem" can go much further (20-30 moves ahead)


Edit : To clarify, brute force is simplest (dumbest?) way to explore the space of solutions. If you have a problem is set in a countable space (chess moves are countable, passwords are countable, continuous stuff is uncountable) brute force will explore this space considering all solutions equally. In the chess example, you want to checkmate your opponent. This is done via a sequence of moves, which is countable. Brute force will go through all sequence of moves, however unlikely they may be. The word unlikely is important, because it means that if you have knowledge about your problem (you know what is unlikely to be the solution, like sacrificing your queen), you can do much better than brute force.

like image 99
B. Decoster Avatar answered Oct 19 '22 12:10

B. Decoster