Posted By


HeatPwnz on 01/11/14

Tagged


Statistics


Viewed 103 times
Favorited by 0 user(s)

Related snippets


ophodenje_stabla.h


/ Published in: C++
Save to your folder(s)

header sa funkcijama za ophodenje binarnog stabla


Copy this code and paste it in your HTML
  1. void preorder(element poz, btree *T){
  2. cout << LabelB(poz,T) << " ";
  3. if (LeftChildB(poz,T)) preorder(LeftChildB(poz,T), T);
  4. if (RightChildB(poz,T)) preorder(RightChildB(poz,T), T);
  5. }
  6.  
  7. void inorder(element poz, btree *T){
  8. if (LeftChildB(poz,T)) inorder(LeftChildB(poz,T), T);
  9. cout << LabelB(poz,T) << " ";
  10. if (RightChildB(poz,T)) inorder(RightChildB(poz,T), T);
  11. }
  12.  
  13. void postorder(element poz, btree *T){
  14. if (LeftChildB(poz,T)) postorder(LeftChildB(poz,T), T);
  15. if (RightChildB(poz,T)) postorder(RightChildB(poz,T), T);
  16. cout << LabelB(poz,T) << " ";
  17. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.