reflection and symmetry in back tracking queens

952 views Asked by At

I am reading about Back tracking algorithms in Introduction to design and analysis of algorithms by Anany Levition.

Following is the page which I am referring.

http://books.google.co.in/books?id=mXA_r6mb-s8C&pg=PA399&lpg=PA399&dq=there+are+several+tricks+that+might+reduce+the+size+of+state-space+tree&source=bl&ots=hMb30M4m_2&sig=2ZIT49KTcztgBAVizbssfjYH_Yk&hl=en&sa=X&ei=OeNyVK-CE8fnuQTdnYCACw&ved=0CBwQ6AEwAA#v=onepage&q=there%20are%20several%20tricks%20that%20might%20reduce%20the%20size%20of%20state-space%20tree&f=false

Here author has mentioned as below.

There are several tricks that might help reduce the size of a state-space tree. One is to exploit the symmetry often present in combinational problems. For example, the board of the n-queens problem has several symmetries so that some solutions can be obtained from others by reflection or rotation. This implies, in particular, that we need not consider placements of the first queen in the last floor(n/2) columns, because any solution with the first queen in square (1,i), ceiling(n/2)<= i <=n, can be obtained by reflection (which?) from a solution with the first queen in square(1, n-i+1). This observation cuts the size of the tree by about half.

My questions on above text are

  1. What does author mean by exploit the symmetry often present in combinational problems?

  2. What does author mean by reflection in above context?

  3. In example given above what does author mean by following statement "we need not consider placements of the first queen in the last floor(n/2) columns, because any solution with the first queen in square (1,i), ceiling(n/2)<= i <=n, can be obtained by reflection (which?) from a solution with the first queen in square(1, n-i+1)" ? Here request with example n=4.

1

There are 1 answers

1
amit On

I will try to answer by example on a simplified variation of the problem, it's the same queens problem but on 4x4 board.

One possible solution to the problem is (1,2), (2,4), (3,1),(4,3)

_  _  Q  _
Q  _  _  _ 
_  _  _  Q
_  Q  _  _

Another solution is (2,1), (4,2), (1,3), (4,3):

_  Q  _  _
_  _  _  Q
Q  _  _  _
_  _  Q  _

However, by generating one solution, I could immediately create the other, no need to keep on searching, by simply traversing the coordinates of queen.

The same thing goes the other way around to. If I found that there is no solution that starts with the queens (1,1), (2,1), (_,_), (_,_)

Q  Q  _  _
_  _  _  _
_  _  _  _
_  _  _  _

I could trim beforehand also all the solution that start with the queens (1,1),(1,2),(_,_),(_,_):

Q  _  _  _
Q  _  _  _
_  _  _  _
_  _  _  _

Using symetrical attributes of this problem, whenever I backtrack and trim an unsuccesful branch, I can actually trim other symetrical branches with him as well.