All source code in SQL Ask a SQL Pro Discussion Forum Categories All jobs in SQL
SQL,XML,XSL,Purpose,show,Queens,problem,solve
   Code/Articles � |  Newest/Best � |  Community � |  Jobs � |  Other � |  Goto � | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
SQL Stats

 Code: 81,347. lines
 Jobs: 224. postings

 How to support the site

 
Sponsored by:
Quick Search for:  in language:    
You are in:
 
Login





Latest postings for SQL.
Remove Extra Characters
By Andy Archer on 2/20


Remove Characters
By Andy Archer on 5/18


Click here to put this ticker on your site!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!



 
 
   

N Queens problem

Print
Email
 
article
Submitted on: 2/1/2005 6:35:13 AM
By: Miro Brada  
Level: Intermediate
User Rating: By 2 Users
Compatibility:Oracle, Other

Users have accessed this article 9901 times.
 
author picture
(About the author)
 
     Purpose is to show how the N Queens problem can be solved using SQL. In addition it includes XML, XSL, and Oracle Forms program to display generated solutions.

This article has accompanying files

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
1) You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
The N Queen problem means to find a way to place N queens on NxN chessboard so that no queen attacks any other queen. This problem was firstly introduced on 8x8 chessboard in �Illustrierte Zeitung� in 1850. From that time many people including famous mathematician Karl Friedrich Gauss have paid attention to it. On 4x4 board there are only 2 solutions, on 8x8 one there are already 92 solutions.
This article presents the algorithm (written in PL/SQL) that solves the N Queen problem. Time spent by searching process non-linearly increases by the board size. And it (obviously) depends on server�s capacity as well: my server spent approximately 1 minute for 8x8 board, but almost 30 minutes for 9x9 board. The searching process can be interrupted to continue later on. It is also possible to pass parameter for maximal number of searched solutions.

Although full understanding requires at least intermediate knowledge of PL/SQL, XML, XSL, Oracle Forms, UML, it can be practicing example for beginners. Searching algorithm is written in PL/SQL. Created view, XML, XSL formats, or Queens.fmx (Oracle Forms application), can display solutions.

Download and unzip the file Queens.zip. Then open Queens_ReadMe.doc with instructions.
In short, Queens.zip file contains:
(1) Queens.sql, a PL/SQL executable script creating (a)table tab_Queen, (b) view tab_Queen_View, (c) package bcp_Queens, (d)directory DIR_QUEENS, (e) all solutions for 8x8 board by executing bcp_queens.prc_setqueens(8)
(2) SolutionAlgorithm.jpg, UML scheme
(3) SearchAllSolutions.jpg, UML scheme
(4) Queens.xsl � template to display *.xml files generated by bcp_queens.writeXML procedure
(5) Queens8_4.xml file with reference to Queens.xsl template (open Queens8_4.xml in Mozilla or IE from version 6 to see all solutions for 8x8 board),
(6) additional 4 gif files: b.gif, w.gif, Qb.gif, Qw.gif, used by Queens.xsl template,
(7) Queens.fmx - Oracle Forms application that displays solutions' board according to the board size.

winzip iconDownload article

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.

Virus note:All files are scanned once-a-day by Planet Source Code for viruses,but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:
1)Re-scan downloaded files using your personal virus checker before using it.
2)NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this article, you agree to the following terms...   
1) You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.


Other 2 submission(s) by this author

 

 
 Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:
 
Your Vote!

What do you think of this article(in the Intermediate category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments

 There are no comments on this submission.
 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author from the email account you registered on the site, so you can correspond directly.

NOTICE: The author of this article has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular article, please click here.
 
To post feedback, first please login.


 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Games | Feedback | Customize | SQL Home | Site Home | Other Sites | Open Letter from Moderators | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright� 1997-2010 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.   Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.