backtracking in Date Structures and Algorithm Analysis in C

来源:互联网 发布:excel匹配两列数据 编辑:程序博客网 时间:2024/05/07 09:48


# turnpike reconstruction problem

reconstruct a point set from the distances

This algorithn generally:O(N^2*logN)  but take exponential time in the worst case.

 

If there is no back tracking, the runningtime is O(N^2*logN)

 

but if backtracking happens, theperformance is affected.

 

 


# eight queens

find a placement of 8 queens on a 8*8chessboard such that no two queens are in the same row,column,diagonal,orantidiagonal of the chessboard

 

constrains:

Si = {1,2,3,4,5,6,7,8} for 2<=i<=8

xi != xj if i != j

(xi - xj)/(i-j) != 1 or -1

 

n! candidates in the solution space

 

also using backtracking with a decisiontree

 

 

 

0 0
原创粉丝点击