Dancing Links - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

Dancing Links

Description:

by Donald E.Knuth (Stanford University) 2000.11.15 ... ( ) 1968 Knuth-Morris-Pratt (KMP) – PowerPoint PPT presentation

Number of Views:119
Avg rating:3.0/5.0
Slides: 32
Provided by: zlinkinCo
Category:
Tags: dancing | links

less

Transcript and Presenter's Notes

Title: Dancing Links


1
Dancing Links
  • by Donald E.Knuth (Stanford University)
  • 2000.11.15

2
????
  • ??????
  • ????????????
  • ??
  • ???????????
  • ?????????,?????
  • ???????????????
  • ??????????????????????????????????????????????????
    ?????
  • ??????????

3
????
  • ????
  • 1960??,??LR(k)??? ,?????????
  • 1968?,???????????????,?????????(????,??????,????
    ?)
  • 1968?,??Knuth-Morris-Pratt (KMP)???
  • 1974?,????????????????????,??ACM????????(?????????
    ?)?
  • 1977?-1982? ?????????????????????TeX?METAFONT
    ?(???????????????????)
  • 1994???Concrete Mathematics(????)?
  • 2000?11?,??Dancing Links????????NP?????
  • 2006?7?,?Dancing Links???????????????
  • ??
  • http//www-cs-faculty.stanford.edu/knuth/

4
????
  • ??????
  • ??
  • ??????,??????L?R??,???????????????????????????
  • ???,?????R??????,?????L??????,?????????head,Lhead
    Rheadhead,???????
  • ??????x,??
  • x R L x
  • x L R x

5
????
  • ??????
  • ????
  • LRxLx
  • RLxRx
  • ????
  • Lzx
  • Ryx
  • Rxz
  • Lxy

LX
RX
x
y
z
x
6
Dancing Links
  • ?????????????
  • ????????x , L R x L x , R L
    x R x ??x????????,????(1)?
  • ????????x????????
  • ?????x???,????x???L?R????,???x????????????(1)?????
    ?L R X x , R L x x,????(2)?

7
Dancing Links
  • ??
  • ???x????,L?R??????????????????(?????)
  • ????,??????,???????????????????
  • ??(2)??????????????x,???????(1)?

8
Dancing Links
  • ????????(2)???
  • idea 1????????????,??????????????????
  • idea 2??????????(??N????)?????-??,??????????????
  • idea 1??????,???(2)????????????idea
    2????????(1)???(2)????,????????-???,??????????????
    ????????(Dancing)?
  • ??????????(Links)???(1)???(2)???????????,?Knuth???
    Dancing Links?

9
Exact Cover Problem
  • Exact Cover Problem(??????)
  • ??????MN?0-1??,????????,????????1?
  • ???,??????1?4?5?,?????????????1?1?
  • ????NPC??,??????????????,?????NPC??,???????,??????
    ??????

10
Exact Cover Problem
  • ???????????
  • Knuth????X??,????0-1??A???????????????

??,??2,3??,???????,???5??????
???? ?????1,4,5
11
Exact Cover Problem
  • X???????
  • ??????????,??????????????,??????????????????O(n)??
    ?
  • X?????-???,???????????,?????????????????,?????O(n
    2)?
  • ??????, Knuth???DLX??,?Dancing Links X???

12
DLX
  • ??????????,??????????????,?????,L,R,D,U???????????
    ???????,??C?,????????????,?????1??????????
  • ?????(??????)??????,????S????????????,????????????
    ??(????),????head??????,?????

13
DLX
  • DLX???????,DLX?????????????????search(k),??????k0
    ,?????k????,?????,???????X?????????

14
DLX
  • ?????
  • ???Ok??????????????,?????????????????
  • ???????????,???????????CEF,????????????????,??????
    ?????????

15
DLX
  • ???c
  • ???c?,???????????????,???????????,????????????????
    ????,???????????????,???????

16
DLX
  • ?c???(???)
  • ?c????????????????c??????,?????,??????(1)?????????
    ????,???????????2?????????????

17
DLX
  • ?c???
  • ???????(2)???????,????????????,??????????c????,???
    ??????????

18
????
  • ?????A???

19
????
  • A????,D??G???????
  • ???????

20
????
  • ???????,??????,??????,?????A,D?,????????
  • A D
  • B G
  • C E F

21
????
  • ?????????,????????????,??Knuth????????,?????Scott?
    ????????,???????O(1)??????,??????????????????
  • Scott??,??12????????,??88????,?????????????

22
????
  • ?????????F I L P N T U V W X Y Z,?????????????????
  • ????72????,??12????????,?60?????????
  • ?????????????????????????,??1568??????
  • ??i????????,????????r1,?(i,r1)?1,????????x,?(i,x)?
    1,?????????????(?),?????????(?)????(??)???

23
????
  • ?????????(???????????)???????103005,DLX????????10?
    ???,???????????,???????????????(72
    1568),??1011?,?CPU 108/sec???,????103s,??10????
    ?,?DLX,??1????????300??????

24
????
  • ????N??,Y??,???
  • ?????16?????312,512,659?????5,801,583,789????
  • DLX?????
  • ?????

25
??
  • ??Dancing Links ???????????????DLX??,???????????
    ????????
  • ????????????????????(?N????,??????)???????????????
    ????,?????????????,???????????????????????????,???
    ??????????????
  • Knuth??????????????????Dancing
    Links??????,?????????????????????????

26
???
  • ????
  • ??????????????9x9????,??????1-9???????,??????????
    ???????1-9????????????,?????????9?3x3????????1-9??
    ????????????,??????????,?????????,????3x3??????1-9
    ??????

27
???
  • ????
  • ??????NPC??????,???????????????,??????????????
  • ???????,????????,???????
  • ??????????(r,c,k)????r?c?????k?
  • ???????????,??????r???????k,c???????k,(r,c)???????
    k???b(?????)?????k?
  • ??????NNN999729?,????994324?,????????????
    (?),?????????????????(?)?????(1?1),?????729324?
    ????????
  • ???,(r,c)??????????????????NN?

28
???
  • ?PKU???????(TLE10s),????????(???,?????????????)?D
    LX(??)?????????
  • ????4????????
  • DLX(31ms)
  • ????(531ms)

29
???
  • ???DLX????,????????(???????????),???????????,?????
    ?,???????????1?
  • ??????????????,????????

30
???
  • ??????
  • ??n???,m???,???????k???,??????????????(???????????
    ,????????)
  • ????
  • ?n??????,????????(????????????????,???????????????
    ???)????
  • ?2????????????????????high,0??????low,????????????
    mid,????????r??????c,?(r,c)1?
  • ?????????,???,????????1?1,?????????????k(?????),
    ??DLX?????????

31
Thank You!Q A
??,??????????? ??,?????????? Knuth???????????????
?????, ??,???????????Dancing Links ?????,???????
??????,????????????? ?????,???????????
????Knuth????,??Dancing Links??? ???,???????,?????
?!
Write a Comment
User Comments (0)
About PowerShow.com