From 8effa58a59143842668f4cc80333e4a89916d06d Mon Sep 17 00:00:00 2001 From: krahets Date: Wed, 20 Sep 2023 01:53:44 +0800 Subject: [PATCH] Several bug fixes. --- codes/cpp/chapter_heap/my_heap.cpp | 1 - codes/javascript/chapter_hashing/array_hash_map.js | 1 - codes/typescript/chapter_hashing/array_hash_map.ts | 1 - docs/chapter_array_and_linkedlist/linked_list.md | 4 ++-- docs/chapter_computational_complexity/space_complexity.md | 2 +- docs/chapter_tree/avl_tree.md | 4 ++-- docs/chapter_tree/binary_tree.md | 2 +- 7 files changed, 6 insertions(+), 9 deletions(-) diff --git a/codes/cpp/chapter_heap/my_heap.cpp b/codes/cpp/chapter_heap/my_heap.cpp index a59685f5b..b32e07584 100644 --- a/codes/cpp/chapter_heap/my_heap.cpp +++ b/codes/cpp/chapter_heap/my_heap.cpp @@ -47,7 +47,6 @@ class MaxHeap { while (true) { // 判断节点 i, l, r 中值最大的节点,记为 ma int l = left(i), r = right(i), ma = i; - // 若节点 i 最大或索引 l, r 越界,则无须继续堆化,跳出 if (l < size() && maxHeap[l] > maxHeap[ma]) ma = l; if (r < size() && maxHeap[r] > maxHeap[ma]) diff --git a/codes/javascript/chapter_hashing/array_hash_map.js b/codes/javascript/chapter_hashing/array_hash_map.js index cb0a9bd2f..9c4b1547b 100644 --- a/codes/javascript/chapter_hashing/array_hash_map.js +++ b/codes/javascript/chapter_hashing/array_hash_map.js @@ -83,7 +83,6 @@ class ArrayHashMap { print() { let pairSet = this.entries(); for (const pair of pairSet) { - if (!pair) continue; console.info(`${pair.key} -> ${pair.val}`); } } diff --git a/codes/typescript/chapter_hashing/array_hash_map.ts b/codes/typescript/chapter_hashing/array_hash_map.ts index eba8e69be..0487f17ea 100644 --- a/codes/typescript/chapter_hashing/array_hash_map.ts +++ b/codes/typescript/chapter_hashing/array_hash_map.ts @@ -87,7 +87,6 @@ class ArrayHashMap { public print() { let pairSet = this.entries(); for (const pair of pairSet) { - if (!pair) continue; console.info(`${pair.key} -> ${pair.val}`); } } diff --git a/docs/chapter_array_and_linkedlist/linked_list.md b/docs/chapter_array_and_linkedlist/linked_list.md index fa88fa81b..524b5f6d4 100755 --- a/docs/chapter_array_and_linkedlist/linked_list.md +++ b/docs/chapter_array_and_linkedlist/linked_list.md @@ -22,7 +22,7 @@ class ListNode: """链表节点类""" def __init__(self, val: int): - self.val: int = val # 节点值 + self.val: int = val # 节点值 self.next: ListNode | None = None # 指向下一节点的引用 ``` @@ -739,7 +739,7 @@ class ListNode: """双向链表节点类""" def __init__(self, val: int): - self.val: int = val # 节点值 + self.val: int = val # 节点值 self.next: ListNode | None = None # 指向后继节点的引用 self.prev: ListNode | None = None # 指向前驱节点的引用 ``` diff --git a/docs/chapter_computational_complexity/space_complexity.md b/docs/chapter_computational_complexity/space_complexity.md index 3229534e2..224323360 100755 --- a/docs/chapter_computational_complexity/space_complexity.md +++ b/docs/chapter_computational_complexity/space_complexity.md @@ -28,7 +28,7 @@ class Node: """类""" def __init__(self, x: int): - self.val: int = x # 节点值 + self.val: int = x # 节点值 self.next: Node | None = None # 指向下一节点的引用 def function() -> int: diff --git a/docs/chapter_tree/avl_tree.md b/docs/chapter_tree/avl_tree.md index 63324e7f9..af318367e 100644 --- a/docs/chapter_tree/avl_tree.md +++ b/docs/chapter_tree/avl_tree.md @@ -26,8 +26,8 @@ AVL 树既是二叉搜索树也是平衡二叉树,同时满足这两类二叉 class TreeNode: """AVL 树节点类""" def __init__(self, val: int): - self.val: int = val # 节点值 - self.height: int = 0 # 节点高度 + self.val: int = val # 节点值 + self.height: int = 0 # 节点高度 self.left: TreeNode | None = None # 左子节点引用 self.right: TreeNode | None = None # 右子节点引用 ``` diff --git a/docs/chapter_tree/binary_tree.md b/docs/chapter_tree/binary_tree.md index 408a75094..7fc872c80 100644 --- a/docs/chapter_tree/binary_tree.md +++ b/docs/chapter_tree/binary_tree.md @@ -8,7 +8,7 @@ class TreeNode: """二叉树节点类""" def __init__(self, val: int): - self.val: int = val # 节点值 + self.val: int = val # 节点值 self.left: TreeNode | None = None # 左子节点引用 self.right: TreeNode | None = None # 右子节点引用 ```