* Helper method to check ancestors * Time O(n) | Space O(1) * @param {number} index * @return {boolean}
(index)
| 90 | * @return {boolean} |
| 91 | */ |
| 92 | checkAncestors(index) { |
| 93 | let node = this.parent[index]; |
| 94 | while (node !== -1) { |
| 95 | if (this.treeHash[node]) return false; |
| 96 | node = this.parent[node]; |
| 97 | } |
| 98 | return true; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Helper method to check descendants |