protected function order(AbstractBinaryTree $root = NULL) { if ($root == NULL) { return; } $this->finalData[] = $root->getData(); $this->order($root->getLeftChild()); $this->order($root->getRightChild()); }
protected function order(AbstractBinaryTree $root = NULL) { while (!$this->stack->isEmpty() || $root != NULL) { if ($root != NULL) { $this->finalData[] = $root->getData(); if ($root->getRightChild() != NULL) { $this->stack->push($root->getRightChild()); } $root = $root->getLeftChild(); } else { $root = $this->stack->pop(); } } }
public function __destruct() { //$this->middle = NULL; $this->postOrderDestruct($this); parent::__destruct(); echo 'Mažu ternární strom'; }
public function __destruct() { parent::__destruct(); }
protected function order(AbstractBinaryTree $root = NULL) { $this->finalData[] = $root->getData(); if ($root->getLeftChild() != NULL) { $this->order($root->getLeftChild()); } $this->finalData[] = $root->getData(); if ($root instanceof TernaryTree && $root->getMiddleChild() != NULL) { $this->order($root->getMiddleChild()); $this->finalData[] = $root->getData(); } if ($root->getRightChild() != NULL) { $this->order($root->getRightChild()); } $this->finalData[] = $root->getData(); }