Posted By

HeatPwnz on 01/11/14


Tagged

cpp sp Z4


Versions (?)

ophodenje_stabla.h


 / Published in: C++
 

header sa funkcijama za ophodenje binarnog stabla

  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  

You need to login to post a comment.