类似筛法的N皇后问题求解算法  

Sieve Algorithm to N Queens Problem

在线阅读下载全文

作  者:程元斌[1] 

机构地区:[1]江汉大学数学与计算机科学学院

出  处:《计算机系统应用》2013年第10期147-150,共4页Computer Systems & Applications

摘  要:迄今为止,已有多种基于不同理论的八皇后问题算法.本文提出一种类似筛法的新算法:在棋盘某一格放上一个皇后的同时划去经过这一格的纵、横、及正负45度线上的所有格位,或者说筛去这些格位;后来的皇后只能放在未被占据或划去的格位上;若所有的皇后都能放入一个格位,则得到了一个布局或一个解.依据这种思路容易制定一个N皇后问题的简洁算法.实验结果表明,筛法算法的效率大大高于经典的回溯法.So far, there have been many different algorithm of eight queens problem. A similar sieve algorithm is presented in this paper: Using a algorithm similar to the sieve method in number theory: place the first queen in the first grid of the first row, and mark out the row, the column, the downward diagonal and the upward diagonal through the first queen; then place the second queen on the most left grid of the unmarked grid of the second row, and mark out the row, the column, the downward diagonal and the upward diagonal through the second queen; like this, queens are added, one by one. if all the queens can be placed on the board, a layout or a solution received. Traversing all grids of all row, we would get all solutions of N-queens problem. Based on the simple idea, we can develop a N-queens program easily. The experimental results show that the efficiency of the sieve program is much higher than the classic backtracking program.

关 键 词:N皇后问题 筛法 回溯法 

分 类 号:TP301.6[自动化与计算机技术—计算机系统结构]

 

参考文献:

正在载入数据...

 

二级参考文献:

正在载入数据...

 

耦合文献:

正在载入数据...

 

引证文献:

正在载入数据...

 

二级引证文献:

正在载入数据...

 

同被引文献:

正在载入数据...

 

相关期刊文献:

正在载入数据...

相关的主题
相关的作者对象
相关的机构对象