/ Published in: C++
header sa funkcijama za ophodenje binarnog stabla
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
void preorder(element poz, btree *T){ cout << LabelB(poz,T) << " "; if (LeftChildB(poz,T)) preorder(LeftChildB(poz,T), T); if (RightChildB(poz,T)) preorder(RightChildB(poz,T), T); } void inorder(element poz, btree *T){ if (LeftChildB(poz,T)) inorder(LeftChildB(poz,T), T); cout << LabelB(poz,T) << " "; if (RightChildB(poz,T)) inorder(RightChildB(poz,T), T); } void postorder(element poz, btree *T){ if (LeftChildB(poz,T)) postorder(LeftChildB(poz,T), T); if (RightChildB(poz,T)) postorder(RightChildB(poz,T), T); cout << LabelB(poz,T) << " "; }