12.07.2015 Views

C++ - VideoTutorials-bg.com

C++ - VideoTutorials-bg.com

C++ - VideoTutorials-bg.com

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

{BinOrdTree t;Copy(t.root, root->Left );return t;}template BinOrdTree BinOrdTree::RightTree()const{BinOrdTree t;Copy(t.root, root->Right);return t;}template void BinOrdTree::pr(const node*p) const{if (p){pr(p->Left);cout inf Right);}}Член-функцията Add е помощна. Използва се за реализиране на членфункциятаAddNode на шаблона, чрез която се включва елемент в двоичнонаредено дърво по описания по-горе начин.template void BinOrdTree::Add(node* &p, T const & x)const{if (!p){p = new node;p->inf = x;p->Left = NULL;p->Right = NULL;}elseif (x < p->inf) Add(p->Left, x);else Add(p->Right, x);}Създаването на непразно двоично наредено дърво се осъществява чрезчлен-функцията Create. Тя реализира въвеждане на елементи ивключването им чрез AddNode в двоично наредено дърво.210

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!