Dancing links-nuclear Weapon for Exact Cover problems

Source: Internet
Author: User

Best elaboration on Dancing list I found. In Chinese.

Traditional backtracing is a heuristic-like procedure. Say, there was N items to try with one by one, when N[i] was picked, all rest n[i + 1, N-1] items would being tested one by E, too. What's more, due to recursive calls, there is 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 a helicopter floating above the city. You is able to see all blocks, and does some bookkeeping with constant time!

Dancing Links, enables do a simplified, lightweighted backtracing:

-Say n[i] conflicts with N[J], n[k], etc.. J, K > I, so if N[i] is picked, N[j], n[k] be 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 what wanna recover when backtracing? Similar const time Recover do that! (O (1) List update OPS)

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

Dancing links-nuclear Weapon for Exact Cover problems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.