/ Published in: C++
asdf
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#include <iostream> using namespace std; void AddElement(int x, int root, btree *T){ bool ponovi = true; do{ if(x < LabelB(root,T)){ if(ExistLeftChild(root,T)) root = LeftChildB(root,T); else{ CreateLeftB(x,root,T); ponovi = false; } } else if(x > LabelB(root,T)){ if(ExistRightChild(root,T)) root = RightChildB(root,T); else{ CreateRightB(x,root,T); ponovi = false; } } }while(ponovi); } bool Find(int x, int root, btree *T){ bool ponovi = true; bool nadjen = false; do{ if(x == LabelB(root,T)){ nadjen = true; ponovi = false; } if(x < LabelB(root,T)){ if(ExistLeftChild(root,T)) root = LeftChildB(root,T); else ponovi = false; } else if (x > LabelB(root,T)){ if(ExistRightChild(root,T)) root = RightChildB(root,T); else ponovi = false; } }while(ponovi); return nadjen; }
URL: asdf