Revision: 68513
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 19, 2015 07:35 by akljaic
Initial Code
#include <iostream>
using namespace std;
void preorder(tree *T){
int t = T->first;
cout << t << " ";
if(T->element[t].firstchild!=-1){
T->first = T->element[t].firstchild;
preorder(T);
}
if(T->element[t].nextsibling!=-1){
T->first = T->element[t].nextsibling;
preorder(T);
}
}
void inorder(tree *T){
int t = T->first;
if(T->element[t].firstchild!=-1){
T->first = T->element[t].firstchild;
inorder(T);
}
if(T->element[t].firstchild==-1) cout << t << " ";
int parent = ParentT(t,T);
if(FirstChildT(parent,T)==t) cout << parent << " ";
if(T->element[t].nextsibling!=-1){
T->first = T->element[t].nextsibling;
inorder(T);
}
}
void postorder(tree *T){
int t=T->first;
if(T->element[t].firstchild!=-1){
T->first = T->element[t].firstchild;
postorder(T);
}
cout << t << " ";
if(T->element[t].nextsibling!=-1){
T->first = T->element[t].nextsibling;
postorder(T);
}
}
Initial URL
asdf
Initial Description
asdf
Initial Title
ophodjenje_stabla.b
Initial Tags
Initial Language
C++