Skip to content

Commit f68bbb0

Browse files
authoredDec 28, 2023
Update the book based on the revised second edition (krahets#1014)
* Revised the book * Update the book with the second revised edition * Revise base on the manuscript of the first edition
1 parent 19dde67 commit f68bbb0

File tree

261 files changed

+643
-647
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

261 files changed

+643
-647
lines changed
 

‎codes/c/chapter_backtracking/n_queens.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ void backtrack(int row, int n, char state[MAX_SIZE][MAX_SIZE], char ***res, int
2323
}
2424
// 遍历所有列
2525
for (int col = 0; col < n; col++) {
26-
// 计算该格子对应的主对角线和副对角线
26+
// 计算该格子对应的主对角线和次对角线
2727
int diag1 = row - col + n - 1;
2828
int diag2 = row + col;
29-
// 剪枝:不允许该格子所在列、主对角线、副对角线上存在皇后
29+
// 剪枝:不允许该格子所在列、主对角线、次对角线上存在皇后
3030
if (!cols[col] && !diags1[diag1] && !diags2[diag2]) {
3131
// 尝试:将皇后放置在该格子
3232
state[row][col] = 'Q';
@@ -52,7 +52,7 @@ char ***nQueens(int n, int *returnSize) {
5252
}
5353
bool cols[MAX_SIZE] = {false}; // 记录列是否有皇后
5454
bool diags1[2 * MAX_SIZE - 1] = {false}; // 记录主对角线上是否有皇后
55-
bool diags2[2 * MAX_SIZE - 1] = {false}; // 记录副对角线上是否有皇后
55+
bool diags2[2 * MAX_SIZE - 1] = {false}; // 记录次对角线上是否有皇后
5656

5757
char ***res = (char ***)malloc(sizeof(char **) * MAX_SIZE);
5858
*returnSize = 0;

‎codes/c/chapter_graph/graph_bfs.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int isVisited(Vertex **visited, int size, Vertex *vet) {
5252
return 0;
5353
}
5454

55-
/* 广度优先遍历 BFS */
55+
/* 广度优先遍历 */
5656
// 使用邻接表来表示图,以便获取指定顶点的所有邻接顶点
5757
void graphBFS(GraphAdjList *graph, Vertex *startVet, Vertex **res, int *resSize, Vertex **visited, int *visitedSize) {
5858
// 队列用于实现 BFS
@@ -98,7 +98,7 @@ int main() {
9898
printf("\n初始化后,图为\n");
9999
printGraph(graph);
100100

101-
// 广度优先遍历 BFS
101+
// 广度优先遍历
102102
// 顶点遍历序列
103103
Vertex *res[MAX_SIZE];
104104
int resSize = 0;

0 commit comments

Comments
 (0)
Please sign in to comment.