This commit is contained in:
krahets
2023-11-14 21:31:21 +08:00
parent d5a58e0deb
commit c7794e1a84
5 changed files with 20 additions and 20 deletions

View File

@@ -732,7 +732,7 @@ comments: true
/* 获取索引为 i 节点的父节点的索引 */
parent(i) {
return (i - 1) / 2;
return Math.floor((i - 1) / 2); // 向下取整
}
/* 层序遍历 */
@@ -818,7 +818,7 @@ comments: true
/* 获取索引为 i 节点的父节点的索引 */
parent(i: number): number {
return (i - 1) / 2;
return Math.floor((i - 1) / 2); // 向下取整
}
/* 层序遍历 */