Revision: 38696
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 6, 2011 07:21 by marmomcil
Initial Code
struct element{ labeltype oznaka; int zapisan; }; struct tstablo{ struct element polje[10000]; }; typedef struct tstablo *tree; typedef int node; node ParentB(node n,tree stablo){ if(n==1) return -1; else return ((int)n/2); } node LeftChildB(node n,tree stablo){ if (stablo->polje[2*n].zapisan) return 2*n; else return -1; } node RightChildB(node n,tree stablo){ if (stablo->polje[2*n+1].zapisan) return(2*n+1); else return -1; } labeltype LabelB(node n,tree stablo){ return(stablo->polje[n].oznaka); } void ChangeLabelB(labeltype x, node n,tree stablo){ if (stablo->polje[n].zapisan) stablo->polje[n].oznaka = x; else return; } } node RootB(tree stablo){ return 1; } void CreateLeftB(labeltype x,node n,tree stablo){ if (stablo->polje[2*n].zapisan) return; else{ stablo->polje[2*n].zapisan = -1; stablo->polje[2*n].oznaka = x; } } void CreateRightB(labeltype x,node n,tree stablo){ if (stablo->polje[2*n+1].zapisan) return; else{ stablo->polje[2*n+1].zapisan = -1; stablo->polje[2*n+1].oznaka = x; } } void DeleteB(node n,tree stablo){ node i; stack S; if(!stablo->polje[n].zapisan) return; else{ MakeNullS(&S); if (stablo->polje[2*n].zapisan) PushS(2*n,&S); if (stablo->polje[2*n+1].zapisan) PushS(2*n+1,&S); stablo->polje[n].zapisan=0; while(!IsEmptyS(&S)){ i=TopS(&S); PopS(&S); if (stablo->polje[2*i].zapisan) PushS(2*i,&S); if (stablo->polje[2*i+1].zapisan) PushS(2*i+1,&S); stablo->polje[i].zapisan=0; } } void InitB(tree stablo, node x){ for (int i=0;i<=9999;i++) stablo->polje[i].zapisan=-1; stablo->polje[1].oznaka=x; stablo->polje[1].zapisan=-1; }
Initial URL
Initial Description
Header file bstablo_polje.h - odn. implementacija binarnog stabla pomoću polja
Initial Title
bstablo_polje.h - marmomcil
Initial Tags
Initial Language
C++