单词 | brute force |
释义 | brute forcebrute forcebrute forcebrute forcebrute forcebrute force(programming)The canonical example of a brute-force algorithm isassociated with the "travelling salesman problem" (TSP), aclassical NP-hard problem: Suppose a person is in, say, Boston, and wishes to drive to Nother cities. In what order should the cities be visited inorder to minimise the distance travelled? The brute-force method is to simply generate all possibleroutes and compare the distances; while guaranteed to work andsimple to implement, this algorithm is clearly very stupid inthat it considers even obviously absurd routes (like goingfrom Boston to Houston via San Francisco and New York, in thatorder). For very small N it works well, but it rapidlybecomes absurdly inefficient when N increases (for N = 15,there are already 1,307,674,368,000 possible routes toconsider, and for N = 1000 - well, see bignum). Sometimes,unfortunately, there is no better general solution than bruteforce. See also NP-complete. A more simple-minded example of brute-force programming isfinding the smallest number in a large list by first using anexisting program to sort the list in ascending order, and thenpicking the first number off the front. Whether brute-force programming should actually be consideredstupid or not depends on the context; if the problem is notterribly big, the extra CPU time spent on a brute-forcesolution may cost less than the programmer time it would taketo develop a more "intelligent" algorithm. Additionally, amore intelligent algorithm may imply more long-term complexitycost and bug-chasing than are justified by the speedimprovement. When applied to cryptography, it is usually known as brute force attack. Ken Thompson, co-inventor of Unix, is reported to haveuttered the epigram "When in doubt, use brute force". Heprobably intended this as a ha ha only serious, but theoriginal Unix kernel's preference for simple, robust andportable algorithms over brittle "smart" ones does seem tohave been a significant factor in the success of thatoperating system. Like so many other tradeoffs in softwaredesign, the choice between brute force and complex,finely-tuned cleverness is often a difficult one that requiresboth engineering savvy and delicate aesthetic judgment. |
随便看 |
|
英语词典包含2567994条英英释义在线翻译词条,基本涵盖了全部常用单词的英英翻译及用法,是英语学习的有利工具。