Violent aesthetic search

Violent aesthetic search

  Introduction: In noip, csp game will generally have a large number of points can take part, some questions can be found by storm AC, even nominal also be suspended or beaten. . . In some weak province, to take full points there is violence of a province he says. . . .

   However, in any case, like teachings herein you how to get your bow and arrow more accurate, spear throw farther, even if you have mastered the better, but like other than excellent algorithm guns, laser guns .  The intent of this article is to share some search tips compare use, showing the subtleties of search, experience points when you can write about violence will not fool the title in the examination room. Guns, laser guns occasionally when failed.

  Oier real thinking is not confined to violent search, so when you use the search because some tips mentioned in this article while AC certain topic, please put down your search violence, to comprehend the subject of beauty. Study found violence, the use of violence to search, and search out the storm.


Part.1 search of the definition of violence

  This article talked about violence refers to search data within the scale of affordable, high-speed computing power of computer use, subject to the requirements of answers to find. Generally speaking, there are two different styles search. DFS and BFS. DFS is the depth-first search, typically calls itself recursively, using the parameters of the transfer function of the state. BFS mainly transversely discuss each possible state, the general use queue maintains its state.

DFS and BFS how decisions it?

Overall rate on the mirror is much higher than DFS BFS, it is generally preferred DFS

In general, the case of seeking the optimal solution can be considered BFS, because BFS search order is the prime horizontal development, so the first must be found to the value of the optimum value, but is a transverse BFS search because it is not convenient for pruning optimization

At the same time, DFS can also be simulated by other operations like iterative deepening search laterally, so, it is recommended to make use of DFS; This paper will also take all kinds of talk at great length to optimize the DFS.


 Part.2 DFS optimization of pruning

There are many useless sub-tree in search of DFS trees, these sub-tree or it is not the optimal solution, or even illegal, in order to narrow the search, the purpose of cheat points, here are several commonly used in pruning optimization

First, the memory of pruning

  As the name suggests, the memory of pruning is to have searched the state calculated first survive, such as over again when you need to use can come up with, and this will greatly improve the efficiency of the search, the search can be understood as a perceptual after direct out with once and for all on the line when the next time the search to the state. The pruning is pruning the optimization of all the most obvious, of course, memories of pruning between fact and DP are closely linked, it will wait until later in the detailed story.

Second, the feasibility of pruning

  If the search to find the current state of the state is no longer legitimate, and completely not continue to spend time searching anymore, you can return directly to search out the rest of the state, such as your mother asks you to play up to 1min computer every day, then you find that the boot are used for a minute, you can also roll out the return back to study. .

Third, the optimization of pruning

The scaling method can be used, assuming that the current search state continues, and every time according to an optimal value can not achieve their goals, then you can return swap, for example, if you estimate a job and remaining under the number of days, even if you do find that every day 24h can not complete the remaining work, you can boldly return out (this is not the reason you do not homework)

Fourth, Las Vegas pruning

As we all know, Las Vegas is a casino. . The significance of this pruning is when you find the optimal value of the program to be timed out, and put the current search as to the global optimum output. . . This is compelling gambler behavior.

But it can not fool minutes is really hard to say. . . . Use can look at the situation. Code is very simple to achieve, a recording Cnt, once every recursive Cnt ++; return Cnt to greater than a certain value

Fifth, the probability of pruning

  This is a metaphysical algorithm, whether AC depends on your face. . . . Simulated annealing algorithm is a probabilistic pruning, probably mean that every search have a certain probability to continue the search down, with the deepening of the search, the probability down the search will be smaller, similar to annealing physical process, of course, continue to search the probability is set by yourself, you can also do what the valuation function to calculate the probability of the current search continues to go on. . . . . All metaphysics, have the opportunity to go into the details later.

There are some other pruning techniques, such as heuristic search friends like, the classification will speak in detail about the mainstream search optimization.


 

 Part 3. some excellent search skills

A, Meet in the middle binary search / bidirectional DFS

 1. Why perform a binary search?

Generally, in the search tree, the size of the search is that as the size of data growing exponentially, so if you can halve the size of the data that will significantly reduce the size of the search.

2. What problems can use binary search

  Binary search for smaller data title (to ensure that the size of the binary data can still acceptable), while the search for answers can be searched by the merger of two parts separated solving.

3. Vs binary search segment-shaped pressure

  n value is within the general topic 40, there are two alternative solution, and the segment-like pressure binary search. The time complexity of binary search is usually better, if coupled with some other pruning will be able to run faster.

Guess you like

Origin www.cnblogs.com/pveds/p/11802257.html