Tony's Log

Algorithms, Distributed System, Machine Learning

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

http://www.cnblogs.com/grenet/p/3145800.html
Best elaboration on dancing list I found. in Chinese.

Traditional backtracing is a heuristic-like procedure. Say, there are N items to try with one by one, when N[i] is picked, all rest N[i + 1, N-1] items would be tested one by one, too. What's more, due to recursive calls, there are a lot intermediate caching necessary to contain intermediate states. Very blindly procedure correct?

Traditional backtracing is like, you are trying to find a place on the ground, because you cannot see through blocks.. OK, so the computer god Donald Knuth invented a smarter tool - dancing links. This is like, find a place on a helicopter floating above the city. You are able to see all blocks, and do some bookkeeping with constant time!

Dancing Links, enables you to do a simplified, lightweighted backtracing:

- Say N[i] conflicts with N[j], N[k], etc.. j, k > i, so when N[i] is picked, N[j], N[k] are eliminated (O(1) list update ops) from candidate list automatically!

- During above procedures, you don't need extra buffer to store intermediate states: modified dancing links it is! So you wanna recover when backtracing? Similar const time recover do that! (O(1) list update ops)

Here is a more complex and interesting example:
http://m.blog.csdn.net/blog/mu399/7627862 (Tetris, Sudoku, N-Queens)

posted on 2015-03-05 07:38  Tonix  阅读(155)  评论(0编辑  收藏  举报