Several bug fixes.

This commit is contained in:
krahets 2023-09-20 01:53:44 +08:00
parent 53d91db10d
commit 8effa58a59
7 changed files with 6 additions and 9 deletions

View file

@ -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])

View file

@ -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}`);
}
}

View file

@ -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}`);
}
}

View file

@ -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 # 指向前驱节点的引用
```

View file

@ -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:

View file

@ -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 # 右子节点引用
```

View file

@ -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 # 右子节点引用
```