Simplify struct declarations of C.

Use PascalCase for all structs in C.
SImplify n_queens.c
Format C code for chapter of graph.
This commit is contained in:
krahets
2023-10-18 02:16:26 +08:00
parent 070d23ee6e
commit 1e49574332
35 changed files with 503 additions and 599 deletions

View File

@ -147,12 +147,10 @@
```c title=""
/* 链表节点结构体 */
struct ListNode {
typedef struct ListNode {
int val; // 节点值
struct ListNode *next; // 指向下一节点的指针
};
typedef struct ListNode ListNode;
} ListNode;
/* 构造函数 */
ListNode *newListNode(int val) {
@ -617,13 +615,11 @@
```c title=""
/* 双向链表节点结构体 */
struct ListNode {
typedef struct ListNode {
int val; // 节点值
struct ListNode *next; // 指向后继节点的指针
struct ListNode *prev; // 指向前驱节点的指针
};
typedef struct ListNode ListNode;
} ListNode;
/* 构造函数 */
ListNode *newListNode(int val) {

View File

@ -181,14 +181,12 @@ AVL 树既是二叉搜索树也是平衡二叉树,同时满足这两类二叉
```c title=""
/* AVL 树节点结构体 */
struct TreeNode {
TreeNode struct TreeNode {
int val;
int height;
struct TreeNode *left;
struct TreeNode *right;
};
typedef struct TreeNode TreeNode;
} TreeNode;
/* 构造函数 */
TreeNode *newTreeNode(int val) {

View File

@ -157,14 +157,12 @@
```c title=""
/* 二叉树节点结构体 */
struct TreeNode {
typedef struct TreeNode {
int val; // 节点值
int height; // 节点高度
struct TreeNode *left; // 左子节点指针
struct TreeNode *right; // 右子节点指针
};
typedef struct TreeNode TreeNode;
} TreeNode;
/* 构造函数 */
TreeNode *newTreeNode(int val) {
@ -594,9 +592,9 @@
<p align="center"><id> &nbsp; 二叉树的最佳与最差情况 </p>
| | 完美二叉树 | 链表 |
| ----------------------------- | ---------- | ---------- |
| 第 $i$ 层的节点数量 | $2^{i-1}$ | $1$ |
| 高度 $h$ 树的叶节点数量 | $2^h$ | $1$ |
| 高度 $h$ 树的节点总数 | $2^{h+1} - 1$ | $h + 1$ |
| 节点总数 $n$ 树的高度 | $\log_2 (n+1) - 1$ | $n - 1$ |
| | 完美二叉树 | 链表 |
| ----------------------- | ------------------ | ------- |
| 第 $i$ 层的节点数量 | $2^{i-1}$ | $1$ |
| 高度 $h$ 树的叶节点数量 | $2^h$ | $1$ |
| 高度 $h$ 树的节点总数 | $2^{h+1} - 1$ | $h + 1$ |
| 节点总数 $n$ 树的高度 | $\log_2 (n+1) - 1$ | $n - 1$ |