public function is_empty()
 {
     return parent::is_empty() && $this->key === null;
 }
Exemplo n.º 2
0
<?php

require_once "BinTree.php";
$binTree = new BinTree();
$binTree->insert(5);
$binTree->insert(11);
$binTree->insert(3);
$binTree->insert(1);
$binTree->insert(7);
$binTree->showValuesPrefix($binTree->rootNode);
echo "\n";
$binTree->showValuesInfix($binTree->rootNode);
echo "\n";
echo $binTree->search($binTree->rootNode, 3);
echo "\n";
echo $binTree->search($binTree->rootNode, 14);
echo "\n";
Exemplo n.º 3
0
 public static function balancear(BinTree &$bt)
 {
     $e = $bt->maior_afluente();
     if ($e != null) {
         $e->parent_node = $bt->parent_node;
         $bt->parent_node = null;
         $bt->setEsquerda(null);
         $bt->setDireita(null);
         $e->inserir($bt);
         $bt = $e;
     }
 }