This commit is contained in:
krahets
2023-05-21 19:29:43 +08:00
parent 0c64fc7315
commit 5a68f683b9
26 changed files with 93 additions and 93 deletions
+4 -4
View File
@@ -2,7 +2,7 @@
comments: true
---
# 13.2.   全排列问题
# 12.2.   全排列问题
全排列问题是回溯算法的一个典型应用。它的定义是在给定一个集合(如一个数组或字符串)的情况下,找出这个集合中元素的所有可能的排列。
@@ -18,7 +18,7 @@ comments: true
</div>
## 13.2.1. &nbsp; 无重复的情况
## 12.2.1. &nbsp; 无重复的情况
!!! question "输入一个整数数组,数组中不包含重复元素,返回所有可能的排列。"
@@ -342,7 +342,7 @@ comments: true
<p align="center"> Fig. 全排列剪枝示例 </p>
## 13.2.2. &nbsp; 考虑重复的情况
## 12.2.2. &nbsp; 考虑重复的情况
!!! question "输入一个整数数组,**数组中可能包含重复元素**,返回所有不重复的排列。"
@@ -690,7 +690,7 @@ comments: true
<p align="center"> Fig. 两种剪枝条件的作用范围 </p>
## 13.2.3. &nbsp; 复杂度分析
## 12.2.3. &nbsp; 复杂度分析
假设元素两两之间互不相同,则 $n$ 个元素共有 $n!$ 种排列(阶乘);在记录结果时,需要复制长度为 $n$ 的列表,使用 $O(n)$ 时间。因此,**时间复杂度为 $O(n!n)$** 。