Exemplo n.º 1
0
 /**
  * @param BinarySearchTreeNode $node
  * @return bool
  */
 public function successor(BinarySearchTreeNode $node)
 {
     if (null === $node->getRight()) {
         while ($node->getParent()) {
             if ($node->isLeftChild()) {
                 return $node->getParent();
             }
             $node = $node->getParent();
         }
     } else {
         $rightTree = new BinarySearchTree();
         $rightTree->setRoot($node->getRight());
         return $rightTree->max();
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * @param $value
  * @return bool
  */
 public function insert($value)
 {
     return parent::insert($value);
 }
Exemplo n.º 3
0
 public function testHeight()
 {
     self::assertEquals(6, $this->binarySearchTree->calculateHeight());
 }