Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Brute-force search
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Problem-solving technique and algorithmic paradigm}} {{about|the problem-solving technique in computer science|similarly named methods in other disciplines|Brute force (disambiguation)}} {{More citations needed|date=February 2008}} In [[computer science]], '''brute-force search''' or '''exhaustive search''', also known as '''generate and test''', is a very general [[problem-solving]] technique and [[algorithmic paradigm]] that consists of [[Iteration#Computing|systematically checking]] all possible candidates for whether or not each candidate satisfies the problem's statement. A brute-force algorithm that finds the [[divisor]]s of a [[natural number]] ''n'' would enumerate all integers from 1 to n, and check whether each of them divides ''n'' without remainder. A brute-force approach for the [[eight queens puzzle]] would examine all possible arrangements of 8 pieces on the 64-square chessboard and for each arrangement, check whether each (queen) piece can attack any other.<ref>{{Cite web|date=2020-01-06|title=Brute Force Algorithms Explained|url=https://www.freecodecamp.org/news/brute-force-algorithms-explained/|access-date=2021-04-11|website=freeCodeCamp.org|language=en}}</ref> {{Quote box|1=When in doubt, use brute force.|2=[[Ken Thompson]]|3=attributed|fontsize=125%}} While a brute-force search is simple to implement and will always find a solution if it exists, implementation costs are proportional to the number of candidate solutions{{snd}}which in many practical problems tends to grow very quickly as the size of the problem increases ([[#Combinatorial explosion|§Combinatorial explosion]]).<ref>{{cite web |title=Complexity of brute force search |url=https://www.coursera.org/learn/ml-clustering-and-retrieval/lecture/5R6q3/complexity-of-brute-force-search |website=coursera |access-date=14 June 2018}}</ref> Therefore, brute-force search is typically used when the problem size is limited, or when there are problem-specific [[heuristic (computer science)|heuristic]]s that can be used to reduce the set of candidate solutions to a manageable size. The method is also used when the simplicity of implementation is more important than processing speed. This is the case, for example, in critical applications where any errors in the [[algorithm]] would have very serious consequences or when [[automated theorem proving|using a computer to prove a mathematical theorem]]. Brute-force search is also useful as a baseline method when [[benchmarking]] other algorithms or [[metaheuristic]]s. Indeed, brute-force search can be viewed as the simplest metaheuristic. Brute force search should not be confused with [[backtracking]], where large sets of solutions can be discarded without being explicitly enumerated (as in the textbook computer solution to the eight queens problem above). The brute-force method for finding an item in a table{{snd}}namely, check all entries of the latter, sequentially{{snd}}is called [[linear search]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)