This commit is contained in:
krahets
2023-07-16 04:18:52 +08:00
parent c342ba3ced
commit edcd1e5c10
21 changed files with 475 additions and 67 deletions

View File

@@ -2,7 +2,7 @@
comments: true
---
# 12.4.   N 皇后问题
# 13.4.   N 皇后问题
!!! question
@@ -496,7 +496,7 @@ comments: true
[class]{}-[func]{nQueens}
```
## 12.4.1.   复杂度分析
## 13.4.1.   复杂度分析
逐行放置 $n$ 次,考虑列约束,则从第一行到最后一行分别有 $n, n-1, \cdots, 2, 1$ 个选择,**因此时间复杂度为 $O(n!)$** 。实际上,根据对角线约束的剪枝也能够大幅地缩小搜索空间,因而搜索效率往往优于以上时间复杂度。