# Statistics

Viewed 485 times
Favorited by 0 user(s)

# bin_pokazivac.h

/ Published in: C++
`struct pelement{       int label;       pelement *left, *right;       }; pelement *InitB(int x, pelement *T){        T= new pelement;        T-> left= 0;        T-> right= 0;        T-> label= x;        return T;        } pelement *RootB(pelement *T){        return T;        } pelement *ParentB(int n, pelement *T){         if(T->label== n) return 0;         if(T-> left){               if(T-> left-> label== n) return T;               ParentB(n, T-> left);               }        if(T-> right){               if(T-> right-> label== n) return T;               ParentB(n, T-> right);               }        } pelement *LeftChildB(pelement *T){        return T-> left;        } pelement *RightChildB(pelement *T){        return T-> right;        } int LabelB(pelement *T){    return T-> label;    } void ChangeLabelB(int x, pelement *T){     T->label = x;     } void CreateLeftB(int x, pelement *T){    if(T-> left) return;     pelement *novi= new pelement;    novi-> label= x;    novi-> left= 0;    novi-> right= 0;    T-> left= novi;    } void CreateRightB(int x, pelement *T){    if(T-> right) return;     pelement *novi= new pelement;    novi-> label= x;    novi-> left= 0;    novi-> right= 0;    T-> right= novi;    } void DeleteB(pelement *pom, pelement *T){    pelement *erase= pom;     if(pom!= T){             pelement *roditelj= ParentB(pom-> label, T);             if(roditelj-> left== pom) roditelj-> left = NULL;             else roditelj-> right= NULL;             }     if(pom-> left) DeleteB(pom-> left, T);    if(pom-> right) DeleteB(pom-> right, T);    delete erase;    }`