Return to Snippet

Revision: 65692
at January 12, 2014 00:37 by mvracan


Initial Code
#include<iostream>
using namespace std;
 
void PreOrder(tree *T){
    int t=T->root;
    cout << t << " ";
    if(T->polje[t].child!=-1){
        T->root = T->polje[t].child;
        PreOrder(T);
        }
    if(T->polje[t].brother!=-1){
        T->root = T->polje[t].brother;
        PreOrder(T);
        }
    }
 
void PostOrder(tree *T){
    int t=T->root;
    if(T->polje[t].child!=-1){
        T->root = T->polje[t].child;
        PostOrder(T);
        }
    cout << t << " ";
    if(T->polje[t].brother!=-1){
        T->root = T->polje[t].brother;
        PostOrder(T);
        }
    }
 
void InOrder(tree *T){
    int t=T->root;
    if(T->polje[t].child!=-1){
        T->root = T->polje[t].child;
        InOrder(T);
        }
    if(T->polje[t].child==-1) cout << t << " ";
    int parent = ParentT(t,T);
    if(FirstChildT(parent,T)==t) cout << parent << " ";
    if(T->polje[t].brother!=-1){
        T->root = T->polje[t].brother;
        InOrder(T);
        }
    }

Initial URL


Initial Description
zadatak4

Initial Title
ophodenje stabla.h

Initial Tags


Initial Language
C++