Beispiel #1
0
<?php

require 'TreeRB.php';
$tree = new TreeRB();
//populando array
$alfa = range("A", "R");
for ($i = 0; $i < 1000; ++$i) {
    $key = rand() % 9 + 1;
    if ($tree->findNode($key)) {
        $tree->deleteNode($key);
    } else {
        $tree->insertNode($key, $alfa[$key]);
    }
}
//$tree->preOrder($Tree->root);
// foreach ($tree->root as $va1lue) {
// 	echo $va1lue . "<br>";
// }
print_r($tree);
//print_r($tree->root);
//print("iiii");
//$tree->preOrder($tree->root);
Beispiel #2
0
 public function __construct()
 {
     self::$nil = new Node(self::COLOR_BLACK);
     $this->root = self::$nil;
 }