Sudoku Programmers Forum Index

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log inLog in          Games  Calendar

Log in to check your private messagesLog in to check your private messages   

some help with DLX and knuth's paper

 
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> The mathematics of sudoku
View previous topic :: View next topic  
Author Message
furtivefelon

Joined: 25 Dec 2006
Posts: 5
:

Items
PostPosted: Mon Dec 25, 2006 3:45 am    Post subject: some help with DLX and knuth's paper Reply with quote

hello, i have a question regarding doubly linked list, i understand in a general sense what is a doubly linked list, its a list where each element is linked to the previous and next element in that same list.

However, in knuth's paper, he used the following notation in the beginning:

L[R[x]] <- L[x], R[L[x]] <- R[x] removes the x from the list

Now i don't quite understand what does he mean by the error, does he mean insert R[x] into R[L[x]] and vise versa? If he does, can someone please explain exactly how, since i didn't quite get it, thanks alot! Very Happy
Back to top
View user's profile Send private message
Ruud
Site Admin
Joined: 17 Sep 2005
Posts: 708
:
Location: Netherlands

Items
PostPosted: Mon Dec 25, 2006 1:04 pm    Post subject: Reply with quote

Hi,
your interpretation is correct. "<-" must be read as "=" or ":=" depending on the programming language you use.
For a more object-oriented version, read: http://www.sudopedia.org/wiki/Dancing_Links

Ruud
Back to top
View user's profile Send private message Visit poster's website
furtivefelon

Joined: 25 Dec 2006
Posts: 5
:

Items
PostPosted: Tue Dec 26, 2006 3:44 am    Post subject: Reply with quote

nice page! thanks alot for the link Very Happy
Back to top
View user's profile Send private message
furtivefelon

Joined: 25 Dec 2006
Posts: 5
:

Items
PostPosted: Tue Dec 26, 2006 3:57 am    Post subject: Reply with quote

mmm.. just wondering, why would it be L[R[x]] instead of just x (afterall, the element to the left of the right element of x is just x right?)

I'm pretty confused about that..

Thanks again!
Back to top
View user's profile Send private message
Pat

Joined: 06 Sep 2006
Posts: 128
:

Items
PostPosted: Thu Dec 28, 2006 2:50 pm    Post subject: re: doubly-linked list Reply with quote

furtivefelon wrote:
mmm.. just wondering, why would it be L[R[x]] instead of just x (afterall, the element to the left of the right element of x is just x right?)

I'm pretty confused about that..

Thanks again!


hi furtivefelon,

instead of this -
Quote:

to remove x from the list -

Code:

L [ R [x] ] := L [x]
R [ L [x] ] := R [x]



- try using intermediate variables for better understanding -
Quote:

to remove x from the list -

Code:

my_Right := R [x]  ; L [ my_Right ] := L [x]
my_Left  := L [x]  ; R [ my_Left  ] := R [x]



      does this make more sense ?
Back to top
View user's profile Send private message Visit poster's website
MCondron

Joined: 17 Jul 2006
Posts: 35
:
Location: Houston, TX

Items
PostPosted: Fri Dec 29, 2006 3:57 pm    Post subject: Reply with quote

This may also help clear it up...

I think the L[] R[] notation is confusing. They look like function calls or operators or something like that, but they actually are meant to represent data structure members, like this (using the C notation '->' for a structure pointer)

Code:
x->right->left = x->left
x->left->right = x->right


In words, the first assignment makes "left" pointer of the object to x's right point to the object to x's left. The second assignment does similarly for the right. Together, these two assignments remove x from the linked list without destroying x's sense of where in the list it belongs since it's own left and right pointers still point to the correct place. That makes it really easy to put x back into the list:

Code:
x->right->left = x
x->left->right = x

It can be a little confusing at first. Try drawing out the pointers on paper and it will become clear.

Mike
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> The mathematics of sudoku All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Sudoku Programmers topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group

Igloo Theme Version 1.0 :: Created By: Andrew Charron