protected function assertBinaryTree(BinaryTree $root) { $x = $root->value(); $left = $root->left(); if ($left !== null) { $y = $root->left()->value(); $this->assertLessThan($x, $y); $this->assertBinaryTree($root->left()); } $right = $root->right(); if ($right !== null) { $y = $right->value(); $this->assertLessThan($y, $x); $this->assertBinaryTree($root->right()); } }
private function next_valueNotNull() { $right = $this->value->right(); if ($right !== null) { $this->stack->push($right); } $this->next_push($this->value->left()); }
/** * @param BinaryTree $node * @return int */ private function deleteSelectState(BinaryTree $node) { $state = 0; $state |= ($node->right() != null) << 0; $state |= ($node->left() != null) << 1; return $state; }
private function reCalculateHeights(BinaryTree $root = null) { if ($root === null) { return; } $this->reCalculateHeights($root->left()); $this->reCalculateHeights($root->right()); $root->recalculateHeight(); }