English 中文(简体)
麻木问题与复方疗法
原标题:maze problem and Recursive backtracker algorithm

i 想实施回收后转轨法,以解决马奇问题,但可以理解2.3指挥部(“拆除目前囚室和选定牢房之间的隔离墙”)会帮助我吗?

  1. Mark the current cell as Visited
  2. If the current cell has any neighbours which have not been visited
    1. Choose randomly one of the unvisited neighbours
    2. add the current cell to the stack
    3. remove the wall between the current cell and the chosen cell
    4. Make the chosen cell the current cell
    5. Recursively call this function
  3. else
    1. remove the last current cell from the stack
    2. Backtrack to the previous execution of this function

Edit In fact I want an algorithm to solve maze problem by using stack.

问题回答

这一算法是马齐雷generator而不是马齐雷solver<>。 想法是,你想制造一种随意的马奇。 你们也希望马齐格的所有要点都能从所有其他方面得到。

如果你只是任意拆除了隔离墙,那么你的马齐格人很可能不会连接起来。 回收回轨算法通过随机创建walk<>em>和拆除沿该随机行的隔离墙来予以考虑。 休养背道部分使你能够步入马齐的每个牢房,即使你到达死端。

页: 1 通常,你应当这样做

  1. If the current cell is the exit, then finished
  2. If the current cell has any neighbours which have not been visited that are not walls
    1. Choose randomly one of the unvisited non-wall neighbours
    2. add the current cell to the stack
    3. nothing
    4. Make the chosen cell the current cell
    5. Recursively call this function
  3. else
    1. remove the last current cell from the stack
    2. Backtrack to the previous execution of this function

拆除隔离墙就意味着拆除隔离墙! 你们首先用一个囚室网,每座牢房都完全四座墙。 当你随意走动(2.1)时,你将隔离墙带走。





相关问题
How to add/merge several Big O s into one

If I have an algorithm which is comprised of (let s say) three sub-algorithms, all with different O() characteristics, e.g.: algorithm A: O(n) algorithm B: O(log(n)) algorithm C: O(n log(n)) How do ...

Grokking Timsort

There s a (relatively) new sort on the block called Timsort. It s been used as Python s list.sort, and is now going to be the new Array.sort in Java 7. There s some documentation and a tiny Wikipedia ...

Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Enumerating All Minimal Directed Cycles Of A Directed Graph

I have a directed graph and my problem is to enumerate all the minimal (cycles that cannot be constructed as the union of other cycles) directed cycles of this graph. This is different from what the ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...