# Posted By

sasacalopa on 01/06/11

# Statistics

Viewed 325 times
Favorited by 0 user(s)

# bstablo_polje.h

/ Published in: C++
`#ifndef BSTABLO_POKAZIVAC_H #ifndef BSTABLO_POLJE_H#define BSTABLO_POLJE_H struct element{    labeltype label;    int used;};struct bt{    struct element elements[MAX_EL];};typedef struct bt *btree;typedef int node; btree InitB(labeltype x,btree T){     T = new bt;     T->elements[1].label = x;     T->elements[1].used = 1;     return T;}node ParentB(node n,btree T){     if(T==NULL) return 0;     if(n<2) return LAMBDA;     return n/2;}node LeftChildB(node n,btree T){      if(T->elements[2*n].used == PRAZNO) return LAMBDA;     return 2*n;}node RightChildB(node n,btree T){     if(T->elements[2*n+1].used == PRAZNO) return LAMBDA;     return 2*n+1;     }labeltype LabelB(node n,btree T){     if(T==NULL) return 0;     if(T->elements[n].used == PRAZNO) return LAMBDA;     return T->elements[n].label;}void ChangeLabelB(labeltype x,node n,btree T){     T->elements[n].label = x;}node RootB(btree T){     if(T==NULL) return 0;     if(T->elements[1].used == PRAZNO) return LAMBDA;     return 1;}int CreateLeftB(labeltype x,node n,btree T){     if(T->elements[2*n].used == PUNO) return GRESKA;     T->elements[2*n].used = PUNO;     T->elements[2*n].label = x;     return 0;}int CreateRightB(labeltype x,node n,btree T){     if(T->elements[2*n+1].used == PUNO) return GRESKA;     T->elements[2*n+1].used = PUNO;     T->elements[2*n+1].label = x;     return 0;}bool ExistsLeftChildB(node n,btree T){     if(T==NULL) return LAMBDA;     if(T->elements[n*2].used == PUNO) return true;     return false;}bool ExistsRightChildB(node n,btree T){     if(T==NULL) return LAMBDA;     if(T->elements[n*2+1].used == PUNO) return true;     return false;}void DeleteB(node n,btree T){   if(ExistsLeftChildB(n,T)){       DeleteB(LeftChildB(n,T),T);   }   if(ExistsRightChildB(n,T)){       DeleteB(RightChildB(n,T),T);   }   T->elements[n].used = PRAZNO;} #endif  /*BSTABLO_POLJE_H*/ #endif  /*BSTABLO_POKAZIVAC_H*/`