| @@ 24-34 (lines=11) @@ | ||
| 21 | * |
|
| 22 | * @author Siro Diaz Palazon <[email protected]> |
|
| 23 | */ |
|
| 24 | class BinarySearchTree extends BinaryTreeAbstract { |
|
| 25 | ||
| 26 | public function __construct() { |
|
| 27 | $this->root = null; |
|
| 28 | $this->size = 0; |
|
| 29 | } |
|
| 30 | ||
| 31 | public function createNode($key, $data, $parent = null, $left = null, $right = null) { |
|
| 32 | return new BSTNode($key, $data, $parent, $left, $right); |
|
| 33 | } |
|
| 34 | } |
|
| @@ 22-29 (lines=8) @@ | ||
| 19 | * |
|
| 20 | * @author Siro Diaz Palazon <[email protected]> |
|
| 21 | */ |
|
| 22 | class AVLNode extends BSTNode { |
|
| 23 | public $height; // the node height |
|
| 24 | ||
| 25 | public function __construct($key, $data, $parent = null, $left = null, $right = null) { |
|
| 26 | parent::__construct($key, $data, $parent, $left, $right); |
|
| 27 | $this->height = 0; |
|
| 28 | } |
|
| 29 | } |
|