全排列

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
func fullList(list []int, pos int) {
	size := len(list)

	if pos == size {
		count++
		fmt.Printf("%d %v\n", count, list)
		return
	}

	for i := pos; i < size; i++ {
		list[pos], list[i] = list[i], list[pos]
		appendArr(list, pos+1)
		list[pos], list[i] = list[i], list[pos]
	}
}

堆排序

参考:

https://cloud.tencent.com/developer/article/1366827

https://www.cnblogs.com/cangqinglang/p/15069197.html

DFS & BFS

参考:

https://zhuanlan.zhihu.com/p/386595111