|
|
|
obilazak.h
void preorder(int cvor,treet *stablo){
LabelT(cvor,stablo);
cout<<" ";
if(FirstChildT(cvor,stablo)!=-1)
preorder(FirstChildT(cvor,stablo),stablo);
if(NextSiblingT(cvor,stablo)!=-1)
preorder(NextSiblingT(cvor,stablo),stablo);
};
void inorder(int cvor,treet *stablo){
if(FirstChildT(cvor,stablo)!=-1)
inorder(FirstChildT(cvor,stablo),stablo);
LabelT(cvor, stablo);
cout<< " ";
if (FirstChildT(cvor,stablo)!=-1) {
cvor=FirstChildT(cvor, stablo);
while (NextSiblingT(cvor, stablo)!=-1) {
cvor=NextSiblingT(cvor, stablo);
inorder(cvor,stablo);
}
}
};
void postorder(int cvor,treet *stablo){
if (FirstChildT(cvor, stablo)!=-1)
postorder(FirstChildT(cvor, stablo),stablo);
int temp=cvor;
if (FirstChildT(temp, stablo)!=-1) {
temp=FirstChildT(temp, stablo);
while (NextSiblingT(temp, stablo)!=-1) {
temp=NextSiblingT(temp, stablo);
postorder(temp,stablo);
}
}
LabelT(cvor, stablo);
cout<< " ";
}




There are currently no comments for this snippet.