Posted By


mateom11 on 01/19/15

Tagged


Statistics


Viewed 362 times
Favorited by 0 user(s)

Ophodnja_stabla.h


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

Ophodnja_stabla


Copy this code and paste it in your HTML
  1. #include<iostream>
  2. #include "prvo dijete-sljedeci brat.h"
  3. using namespace std;
  4.  
  5. void Preorder(int t, tree *T){
  6. cout <<t<<" ";
  7. if(FirstChildT(t,T)!=-1)
  8. Preorder(FirstChildT(t,T),T);
  9.  
  10. if(NextSiblingT(t,T)!=-1)
  11. Preorder(NextSiblingT(t,T),T);
  12. }
  13.  
  14. void Inorder(int t,tree *T){
  15. if (FirstChildT(t,T)!=-1)
  16. Inorder(FirstChildT(t,T),T);
  17. cout <<t<<" ";
  18. if(FirstChildT(t,T)!=-1){
  19. t=FirstChildT(t,T);
  20. while(NextSiblingT(t,T)!=-1){
  21. t=NextSiblingT(t,T);
  22. Inorder(t,T);
  23. }
  24. }
  25. }
  26.  
  27. void Postorder(int t,tree *T){
  28. if(FirstChildT(t,T)!=-1)
  29. Postorder(FirstChildT(t,T),T);
  30. int pomkorijen=t;
  31. if(FirstChildT(pomkorijen,T)!=-1){
  32. pomkorijen=FirstChildT(pomkorijen,T);
  33. while(NextSiblingT(pomkorijen,T)!=-1){
  34. pomkorijen=NextSiblingT(pomkorijen,T);
  35. Postorder(pomkorijen,T);
  36. }
  37. }
  38. cout<<t<<" ";
  39. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.