Add code source blocks to the chapter Graph.

Fix "函数" and "方法"
This commit is contained in:
krahets
2023-02-10 01:04:26 +08:00
parent d37c71b928
commit 300016393b
47 changed files with 106 additions and 409 deletions

View File

@@ -19,7 +19,7 @@ typedef struct myList myList;
/* 前置声明 */
void extendCapacity(myList *list);
/* 构造函数 */
/* 构造方法 */
myList *newMyList() {
myList *list = malloc(sizeof(myList));
list->capacity = 10;
@@ -29,7 +29,7 @@ myList *newMyList() {
return list;
}
/* 析构函数 */
/* 析构方法 */
void delMyList(myList *list) {
free(list->nums);
free(list);

View File

@@ -20,7 +20,7 @@ void siftDown(maxHeap *h, int i);
void siftUp(maxHeap *h, int i);
/* 构造函数,根据切片建堆 */
/* 构造方法,根据切片建堆 */
maxHeap *newMaxHeap(int nums[], int size) {
// 所有元素入堆
maxHeap *h = (maxHeap *) malloc(sizeof(maxHeap));

View File

@@ -16,7 +16,7 @@ struct ArrayQueue {
typedef struct ArrayQueue ArrayQueue;
/* 构造函数 */
/* 构造方法 */
ArrayQueue *newArrayQueue(int capacity) {
ArrayQueue *queue = (ArrayQueue *) malloc(sizeof(ArrayQueue));
// 初始化数组
@@ -26,7 +26,7 @@ ArrayQueue *newArrayQueue(int capacity) {
return queue;
}
/* 析构函数 */
/* 析构方法 */
void delArrayQueue(ArrayQueue *queue) {
free(queue->nums);
queue->queCapacity = 0;

View File

@@ -14,7 +14,7 @@ struct linkedListStack {
typedef struct linkedListStack linkedListStack;
/* 构造函数 */
/* 构造方法 */
linkedListStack *newLinkedListStack() {
linkedListStack *s = malloc(sizeof(linkedListStack));
s->top = NULL;
@@ -22,7 +22,7 @@ linkedListStack *newLinkedListStack() {
return s;
}
/* 析构函数 */
/* 析构方法 */
void delLinkedListStack(linkedListStack *s) {
while (s->top) {
ListNode *n = s->top->next;
@@ -80,7 +80,7 @@ int pop(linkedListStack *s) {
/* Driver Code */
int main() {
/* 初始化栈 */
// 构造函数
// 构造方法
linkedListStack *stack = newLinkedListStack();
/* 元素入栈 */
@@ -109,7 +109,7 @@ int main() {
bool empty = isEmpty(stack);
printf("栈是否为空 = %s\n", empty ? "true" : "false");
/* 析构函数 */
/* 析构方法 */
delLinkedListStack(stack);
return 0;
}

View File

@@ -110,7 +110,7 @@ TreeNode *rotate(TreeNode *node) {
return node;
}
/* 递归插入结点(辅助函数 */
/* 递归插入结点(辅助方法 */
TreeNode *insertHelper(TreeNode *node, int val) {
if (node == NULL) {
return newTreeNode(val);
@@ -151,7 +151,7 @@ TreeNode *getInOrderNext(TreeNode *node) {
return node;
}
/* 递归删除结点(辅助函数 */
/* 递归删除结点(辅助方法 */
TreeNode *removeHelper(TreeNode *node, int val) {
TreeNode *child, *grandChild, *temp;
if (node == NULL) {