Posted By


mateocindric on 01/19/15

Tagged


Statistics


Viewed 93 times
Favorited by 0 user(s)

Related snippets


ophodenje_stabla.h


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

ophodenje_stabla.h


Copy this code and paste it in your HTML
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void preorder (int poz){
  5. cout<<LabelT(poz, stablo)<< " ";
  6. if(FirstChildT(poz, stablo)!=-1)
  7. preorder(FirstChildT(poz, stablo));
  8. if(NextSiblingT(poz, stablo)!=-1)
  9. preorder(NextSiblingT(poz, stablo));
  10. }
  11.  
  12. void inorder(int poz){
  13. if(FirstChildT(poz, stablo)!=-1)
  14. inorder(FirstChildT(poz, stablo));
  15. cout << LabelT(poz, stablo) << " ";
  16. if (FirstChildT(poz, stablo)!=-1) {
  17. poz=FirstChildT(poz, stablo);
  18. while (NextSiblingT(poz, stablo)!=-1) {
  19. poz=NextSiblingT(poz, stablo);
  20. inorder(poz);
  21. }
  22. }
  23. }
  24.  
  25. void postorder(int poz){
  26. if(FirstChildT(poz, stablo)!=-1)
  27. postorder(FirstChildT(poz, stablo));
  28. int pozv=poz;
  29. if(FirstChildT(pozv, stablo)!=-1){
  30. pozv=FirstChildT(pozv, stablo);
  31. while (NextSiblingT(pozv, stablo)!=-1){
  32. pozv=NextSiblingT(pozv, stablo);
  33. postorder(pozv);
  34. }
  35. }
  36. cout << LabelT(poz, stablo)<< " ";
  37. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.