Knowledge (XXG)

Brute-force search

Source 📝

588:
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.
43: 555:. In 2005, all chess game endings with six pieces or less were solved, showing the result of each position if played perfectly. It took ten more years to complete the tablebase with one more chess piece added, thus completing a 7-piece tablebase. Adding one more piece to a chess ending (thus making an 8-piece tablebase) is considered intractable due to the added combinatorial complexity. 532:
have 10! = 3,628,800 candidates to consider, which a typical PC can generate and test in less than one second. However, adding one more letter – which is only a 10% increase in the data size – will multiply the number of candidates by 11, a 1000% increase. For 20 letters, the number of candidates is 20!, which is about 2.4×10 or 2.4
232:, 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 – namely, check all entries of the latter, sequentially – is called 531:
natural number, which has about 19 decimal digits on the average, the search will take about 10 years. This steep growth in the number of candidates, as the size of the data increases, occurs in all sorts of problems. For instance, if we are seeking a particular rearrangement of 10 letters, then we
580:
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
587:
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
759:
the data to be encoded, something that makes it more difficult for an attacker to recognise when he has cracked the code. One of the measures of the strength of an encryption system is how long it would theoretically take an attacker to mount a successful brute force attack against it.
575:
so that no queen attacks any other. Since each queen can be placed in any of the 64 squares, in principle there are 64 = 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
668:. So if the valid solutions are likely to be "clustered" in some sense, then each new candidate should be as far as possible from the previous ones, in that same sense. The converse holds, of course, if the solutions are likely to be spread out more uniformly than expected by chance. 510:
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
600:
running time of a brute force search will often depend on the order in which the candidates are tested. As a general rule, one should test the most promising candidates first. For example, when searching for a proper divisor of a random number
196:
and will always find a solution if it exists, implementation costs are proportional to the number of candidate solutions – which in many practical problems tends to grow very quickly as the size of the problem increases
708:
tree of all possible moves for the remainder of the game, a more limited tree of minimax possibilities is computed, with the tree being pruned at a certain number of moves, and the remainder of the tree being approximated by a
754:
used in the encryption determines the practical feasibility of performing a brute force attack, with longer keys exponentially more difficult to crack than shorter ones. Brute force attacks can be made less effective by
498:. The algorithm is easily modified to stop after finding the first solution, or a specified number of solutions; or after testing a specified number of candidates, or after spending a given amount of 660:
of candidates examined before success will be about 6, on the average. On the other hand, if the candidates are enumerated in the order 1,11,21,31...991,2,12,22,32 etc., the expected value of
963: 205:
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.
584:
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.
676:
There are many other search methods, or metaheuristics, which are designed to take advantage of various kinds of partial knowledge one may have about the solution.
684:
principle for searching game trees, that eliminates many subtrees at an early stage in the search. In certain fields, such as language parsing, techniques such as
189:
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.
956: 664:
will be only a little more than 2.More generally, the search space should be enumerated in such a way that the next candidate is most likely to be valid,
656:, but each bit thereafter is equal to the previous one with 90% probability. If the candidates are enumerated in increasing order, 1 to 1000, the number 624:. Moreover, the probability of a candidate being valid is often affected by the previous failed trials. For example, consider the problem of finding a 318:. A convenient way to do that is to return a "null candidate", some conventional data value Λ that is distinct from any real candidate. Likewise the 688:
can exploit constraints in the problem to reduce an exponential complexity problem into a polynomial complexity problem. In many cases, such as in
949: 519:
has sixteen decimal digits, say, the search will require executing at least 10 computer instructions, which will take several days on a typical
827: 870: 802: 747:) by an attacker who is unable to take advantage of any weakness in an encryption system that would otherwise make his or her task easier. 60: 700:
languages. The search space for problems can also be reduced by replacing the full problem with a simplified version. For example, in
1215: 902: 126: 107: 689: 79: 30:
This article is about the problem-solving technique in computer science. For similarly named methods in other disciplines, see
563:
One way to speed up a brute-force algorithm is to reduce the search space, that is, the set of candidate solutions, by using
64: 86: 1141: 1111: 1096: 202: 201:). Therefore, brute-force search is typically used when the problem size is limited, or when there are problem-specific 31: 93: 1210: 1166: 1040: 1030: 1010: 53: 1045: 921: 213: 845: 75: 1184: 1146: 541: 537: 499: 990: 697: 693: 1050: 1020: 777: 1161: 1136: 1081: 160: 1171: 1156: 1101: 710: 568: 186: 867: 1189: 1091: 1000: 926: 736: 722: 100: 1151: 995: 898: 520: 167:
all possible candidates for whether or not each candidate satisfies the problem's statement.
1131: 1116: 680:
can also be used to make an early cutoff of parts of the search. One example of this is the
536:; and the search will take about 10 years. This unwelcome phenomenon is commonly called the 140: 1106: 874: 156: 972: 931: 701: 597: 175: 547:
One example of a case where combinatorial complexity leads to solvability limit is in
1204: 1121: 1076: 685: 548: 233: 225: 221: 1071: 1035: 1005: 744: 728: 632:. In this case, the candidate solutions are the indices 1 to 1000, and a candidate 577: 528: 229: 217: 605:, it is better to enumerate the candidate divisors in increasing order, from 2 to 941: 181:
would enumerate all integers from 1 to n, and check whether each of them divides
17: 1025: 756: 552: 533: 208:
This is the case, for example, in critical applications where any errors in the
42: 596:
In applications that require only one solution, rather than all solutions, the
1015: 751: 572: 322:
procedure should return Λ if there are no candidates at all for the instance
976: 936: 677: 564: 310:
procedure must also tell when there are no more candidates for the instance
209: 164: 612:, than the other way around – because the probability that 740: 193: 1126: 705: 681: 171: 894:
Understanding Cryptography: A Textbook for Students and Practitioners
853: 490:
are unnecessary.)The brute-force search algorithm above will call
892: 1055: 945: 828:"Is there a freely available online 7 piece Endgame tablebase?" 581:
further restrict the set of candidates to those arrangements.
216:. Brute-force search is also useful as a baseline method when 36: 494:
for every candidate that is a solution to the given instance
326:. The brute-force method is then expressed by the algorithm 743:
can in theory be used against any encrypted data (except a
692:, one can dramatically reduce the search space by means of 224:. Indeed, brute-force search can be viewed as the simplest 402:
For example, when looking for the divisors of an integer
571:
the challenge is to place eight queens on a standard
1064: 983: 567:specific to the problem class. For example, in the 67:. Unsourced material may be challenged and removed. 185:without remainder. A brute-force approach for the 27:Problem-solving technique and algorithmic paradigm 228:. Brute force search should not be confused with 922:A brute-force algorithm to solve Sudoku puzzles. 214:using a computer to prove a mathematical theorem 891:Christof Paar; Jan Pelzl; Bart Preneel (2010). 735:involves systematically checking all possible 957: 212:would have very serious consequences or when 8: 198: 964: 950: 942: 127:Learn how and when to remove this message 192:While a brute-force search is simple to 769: 666:given that the previous trials were not 170:A brute-force algorithm that finds the 739:until the correct key is found. This 696:, that is efficiently implemented in 644:. Now, suppose that the first bit of 7: 65:adding citations to reliable sources 240:Implementing the brute-force search 803:"Complexity of brute force search" 778:"Brute Force Algorithms Explained" 672:Alternatives to brute-force search 302:as appropriate to the application. 25: 704:, rather than computing the full 474:. (In fact, if we choose Λ to be 422:) should return the integer 1 if 690:Constraint Satisfaction Problems 559:Speeding up brute-force searches 41: 628:bit in a given 1000-bit string 52:needs additional citations for 868:"Blocking Brute Force Attacks" 846:"Lomonosov Endgame Tablebases" 426:≥ 1, or Λ otherwise; the call 1: 578:all possible ways of choosing 32:Brute force (disambiguation) 592:Reordering the search space 272:): check whether candidate 1232: 720: 711:static evaluation function 29: 1180: 1216:Iteration in programming 648:is equally likely to be 314:, after the current one 199:§Combinatorial explosion 1185:List of data structures 897:. Springer. p. 7. 542:curse of dimensionality 538:combinatorial explosion 506:Combinatorial explosion 450:, and Λ otherwise; and 249:In order candidate for 165:systematically checking 698:Constraint programming 694:Constraint propagation 253:after the current one 1082:Breadth-first search 879:UVA Computer Science 569:eight queens problem 406:, the instance data 294:): use the solution 220:other algorithms or 161:algorithmic paradigm 155:, is a very general 76:"Brute-force search" 61:improve this article 1172:Topological sorting 1102:Dynamic programming 937:Iteration#Computing 187:eight queens puzzle 1190:List of algorithms 1097:Divide and conquer 1092:Depth-first search 1087:Brute-force search 1001:Binary search tree 927:Brute-force attack 873:2016-12-03 at the 733:brute-force attack 723:Brute-force attack 276:is a solution for 145:brute-force search 1211:Search algorithms 1198: 1197: 996:Associative array 856:on April 6, 2019. 551:. Chess is not a 163:that consists of 153:generate and test 149:exhaustive search 137: 136: 129: 111: 18:Exhaustive search 16:(Redirected from 1223: 1167:String-searching 966: 959: 952: 943: 909: 908: 888: 882: 864: 858: 857: 852:. Archived from 842: 836: 835: 824: 818: 817: 815: 813: 799: 793: 792: 790: 789: 782:freeCodeCamp.org 774: 616:is divisible by 611: 470:is a divisor of 462:) should return 438:) should return 151:, also known as 141:computer science 132: 125: 121: 118: 112: 110: 69: 45: 37: 21: 1231: 1230: 1226: 1225: 1224: 1222: 1221: 1220: 1201: 1200: 1199: 1194: 1176: 1107:Graph traversal 1060: 984:Data structures 979: 973:Data structures 970: 918: 913: 912: 905: 890: 889: 885: 875:Wayback Machine 865: 861: 844: 843: 839: 826: 825: 821: 811: 809: 801: 800: 796: 787: 785: 776: 775: 771: 766: 725: 719: 717:In cryptography 674: 606: 594: 561: 527:is a random 64- 508: 478:+ 1, the tests 466:if and only if 400: 247: 245:Basic algorithm 242: 157:problem-solving 133: 122: 116: 113: 70: 68: 58: 46: 35: 28: 23: 22: 15: 12: 11: 5: 1229: 1227: 1219: 1218: 1213: 1203: 1202: 1196: 1195: 1193: 1192: 1187: 1181: 1178: 1177: 1175: 1174: 1169: 1164: 1159: 1154: 1149: 1144: 1139: 1134: 1129: 1124: 1119: 1114: 1109: 1104: 1099: 1094: 1089: 1084: 1079: 1074: 1068: 1066: 1062: 1061: 1059: 1058: 1053: 1048: 1043: 1038: 1033: 1028: 1023: 1018: 1013: 1008: 1003: 998: 993: 987: 985: 981: 980: 971: 969: 968: 961: 954: 946: 940: 939: 934: 932:Big O notation 929: 924: 917: 914: 911: 910: 903: 883: 866:Mark Burnett, 859: 837: 832:Stack Exchange 819: 794: 768: 767: 765: 762: 721:Main article: 718: 715: 702:computer chess 673: 670: 593: 590: 560: 557: 507: 504: 410:is the number 328: 304: 303: 281: 246: 243: 241: 238: 222:metaheuristics 176:natural number 159:technique and 135: 134: 49: 47: 40: 26: 24: 14: 13: 10: 9: 6: 4: 3: 2: 1228: 1217: 1214: 1212: 1209: 1208: 1206: 1191: 1188: 1186: 1183: 1182: 1179: 1173: 1170: 1168: 1165: 1163: 1160: 1158: 1155: 1153: 1150: 1148: 1145: 1143: 1140: 1138: 1135: 1133: 1130: 1128: 1125: 1123: 1122:Hash function 1120: 1118: 1115: 1113: 1110: 1108: 1105: 1103: 1100: 1098: 1095: 1093: 1090: 1088: 1085: 1083: 1080: 1078: 1077:Binary search 1075: 1073: 1070: 1069: 1067: 1063: 1057: 1054: 1052: 1049: 1047: 1044: 1042: 1039: 1037: 1034: 1032: 1029: 1027: 1024: 1022: 1019: 1017: 1014: 1012: 1009: 1007: 1004: 1002: 999: 997: 994: 992: 989: 988: 986: 982: 978: 974: 967: 962: 960: 955: 953: 948: 947: 944: 938: 935: 933: 930: 928: 925: 923: 920: 919: 915: 906: 904:3-642-04100-0 900: 896: 895: 887: 884: 880: 876: 872: 869: 863: 860: 855: 851: 847: 841: 838: 833: 829: 823: 820: 808: 804: 798: 795: 783: 779: 773: 770: 763: 761: 758: 753: 748: 746: 742: 738: 734: 730: 724: 716: 714: 712: 707: 703: 699: 695: 691: 687: 686:chart parsing 683: 679: 671: 669: 667: 663: 659: 655: 651: 647: 643: 639: 635: 631: 627: 623: 619: 615: 609: 604: 599: 591: 589: 585: 582: 579: 574: 570: 566: 558: 556: 554: 550: 549:solving chess 545: 543: 539: 535: 530: 526: 522: 518: 514: 505: 503: 501: 497: 493: 489: 485: 481: 477: 473: 469: 465: 461: 457: 453: 449: 445: 441: 437: 433: 429: 425: 421: 417: 413: 409: 405: 399: 395: 391: 387: 383: 379: 375: 371: 368: 364: 360: 356: 353: 350: 346: 343: 339: 335: 331: 327: 325: 321: 317: 313: 309: 301: 297: 293: 289: 285: 282: 279: 275: 271: 267: 263: 260: 259: 258: 256: 252: 244: 239: 237: 235: 234:linear search 231: 227: 226:metaheuristic 223: 219: 215: 211: 206: 204: 200: 195: 190: 188: 184: 180: 177: 173: 168: 166: 162: 158: 154: 150: 146: 142: 131: 128: 120: 117:February 2008 109: 106: 102: 99: 95: 92: 88: 85: 81: 78: –  77: 73: 72:Find sources: 66: 62: 56: 55: 50:This article 48: 44: 39: 38: 33: 19: 1147:Root-finding 1086: 1072:Backtracking 1036:Segment tree 1006:Fenwick tree 893: 886: 878: 862: 854:the original 849: 840: 831: 822: 810:. Retrieved 806: 797: 786:. Retrieved 784:. 2020-01-06 781: 772: 749: 745:one-time pad 732: 729:cryptography 726: 675: 665: 661: 657: 653: 649: 645: 641: 637: 636:is valid if 633: 629: 625: 621: 617: 613: 607: 602: 595: 586: 583: 562: 546: 524: 516: 512: 509: 495: 491: 487: 483: 479: 475: 471: 467: 463: 459: 455: 451: 447: 443: 439: 435: 431: 427: 423: 419: 415: 411: 407: 403: 401: 397: 393: 389: 385: 381: 377: 373: 369: 366: 362: 358: 354: 351: 348: 344: 341: 337: 333: 329: 323: 319: 315: 311: 307: 305: 299: 295: 291: 287: 283: 277: 273: 269: 265: 261: 254: 250: 248: 230:backtracking 218:benchmarking 207: 191: 182: 178: 169: 152: 148: 144: 138: 123: 114: 104: 97: 90: 83: 71: 59:Please help 54:verification 51: 1026:Linked list 757:obfuscating 553:solved game 534:quintillion 414:. The call 1205:Categories 1162:Sweep line 1137:Randomized 1065:Algorithms 1016:Hash table 977:algorithms 788:2021-04-11 764:References 752:key length 678:Heuristics 573:chessboard 565:heuristics 203:heuristics 87:newspapers 1157:Streaming 1142:Recursion 540:, or the 398:end while 210:algorithm 194:implement 916:See also 871:Archived 807:coursera 741:strategy 598:expected 515:. So if 482:≥ 1 and 172:divisors 1152:Sorting 1127:Minimax 850:ChessOK 812:14 June 706:minimax 682:minimax 442:+ 1 if 101:scholar 1132:Online 1117:Greedy 1046:String 901:  881:, 2007 502:time. 492:output 380:) 370:output 284:output 103:  96:  89:  82:  74:  1041:Stack 1031:Queue 1011:Graph 991:Array 620:is 1/ 523:. If 486:< 452:valid 446:< 416:first 355:valid 342:while 334:first 320:first 262:valid 174:of a 108:JSTOR 94:books 1112:Fold 1056:Trie 1051:Tree 1021:Heap 975:and 899:ISBN 814:2018 750:The 737:keys 731:, a 464:true 428:next 386:next 367:then 347:≠ Λ 308:next 306:The 80:news 727:In 652:or 610:− 1 529:bit 500:CPU 298:of 147:or 139:In 63:by 1207:: 877:, 848:. 830:. 805:. 780:. 713:. 640:= 544:. 521:PC 396:) 392:, 384:← 376:, 365:) 352:if 349:do 340:) 332:← 290:, 268:, 257:. 236:. 143:, 965:e 958:t 951:v 907:. 834:. 816:. 791:. 662:t 658:t 654:1 650:0 646:P 642:1 638:P 634:c 630:P 626:1 622:c 618:c 614:n 608:n 603:n 525:n 517:n 513:n 496:P 488:n 484:c 480:n 476:n 472:n 468:c 460:c 458:, 456:n 454:( 448:n 444:c 440:c 436:c 434:, 432:n 430:( 424:n 420:n 418:( 412:n 408:P 404:n 394:c 390:P 388:( 382:c 378:c 374:P 372:( 363:c 361:, 359:P 357:( 345:c 338:P 336:( 330:c 324:P 316:c 312:P 300:P 296:c 292:c 288:P 286:( 280:. 278:P 274:c 270:c 266:P 264:( 255:c 251:P 197:( 183:n 179:n 130:) 124:( 119:) 115:( 105:· 98:· 91:· 84:· 57:. 34:. 20:)

Index

Exhaustive search
Brute force (disambiguation)

verification
improve this article
adding citations to reliable sources
"Brute-force search"
news
newspapers
books
scholar
JSTOR
Learn how and when to remove this message
computer science
problem-solving
algorithmic paradigm
systematically checking
divisors
natural number
eight queens puzzle
implement
§Combinatorial explosion
heuristics
algorithm
using a computer to prove a mathematical theorem
benchmarking
metaheuristics
metaheuristic
backtracking
linear search

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.