Posted By

Dragana_Mlikota on 01/12/14


Tagged

stablo algoritam ophoenja


Versions (?)

Tree_order.h


 / Published in: C++
 

stablo algoritam ophođenja

  1. void Preorder(node n, tree * T){
  2. if(n<0) return;
  3. if (NextSiblingT(n, T) != -2){
  4. cout << n << "\t" << LabelT(n, T)
  5. << "\t" << FirstChildT(n, T)
  6. << "\t\t" << NextSiblingT(n, T) << endl;
  7. }
  8. Preorder(FirstChildT(n, T), T);
  9. Preorder(NextSiblingT(n, T), T);
  10. }
  11.  
  12. void Inorder(node n, tree * T){
  13. if(n<0)return;
  14. Inorder(FirstChildT(n, T), T);
  15. if (NextSiblingT(n, T) != -2){
  16. cout << n << "\t" << LabelT(n, T)
  17. << "\t" << FirstChildT(n, T)
  18. << "\t\t" << NextSiblingT(n, T) << endl;
  19. }
  20. Inorder(NextSiblingT(n, T), T);
  21. }
  22.  
  23. void Postorder(node n, tree * T){
  24. if(n<0)return;
  25. Preorder(FirstChildT(n, T), T);
  26. Preorder(NextSiblingT(n, T), T);
  27. if (NextSiblingT(n, T) != -2){
  28. cout << n << "\t" << LabelT(n, T)
  29. << "\t" << FirstChildT(n, T)
  30. << "\t\t" << NextSiblingT(n, T) << endl;
  31. }
  32. }

Report this snippet  

You need to login to post a comment.