mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-09 08:05:35 +08:00
fix: the bug for the array binary tree from ts and js code (#936)
This commit is contained in:
@ -40,7 +40,7 @@ class ArrayBinaryTree {
|
||||
|
||||
/* 获取索引为 i 节点的父节点的索引 */
|
||||
parent(i) {
|
||||
return (i - 1) / 2;
|
||||
return Math.floor((i - 1) / 2); // 向下取整
|
||||
}
|
||||
|
||||
/* 层序遍历 */
|
||||
|
Reference in New Issue
Block a user