Revision: 38663
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 6, 2011 04:20 by jelenah
Initial Code
struct element{ int label; bool used; }; struct bt{ struct element elements[1000]; }; typedef struct bt *btree; typedef int node; btree InitB(int x,btree T){ T = new bt; T->elements[1].label = x; T->elements[1].used = true; 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 == false) return LAMBDA; return 2*n; } node RightChildB(node n,btree T){ if(T->elements[2*n+1].used == false) return LAMBDA; return 2*n+1; } int LabelB(node n,btree T){ if(T==NULL) return 0; if(T->elements[n].used == false) return LAMBDA; return T->elements[n].label; } void ChangeLabelB(int x,node n,btree T){ T->elements[n].label = x; } node RootB(btree T){ if(T==NULL) return 0; if(T->elements[1].used == false) return LAMBDA; return 1; } int CreateLeftB(int x,node n,btree T){ if(T->elements[2*n].used == true) return -1; T->elements[2*n].used = true; T->elements[2*n].label = x; return 0; } int CreateRightB(int x,node n,btree T){ if(T->elements[2*n+1].used == true) return -1; T->elements[2*n+1].used = true; 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 == true) return true; return false; } bool ExistsRightChildB(node n,btree T){ if(T==NULL) return LAMBDA; if(T->elements[n*2+1].used == true) 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 = false; }
Initial URL
Initial Description
jedno od zaglavlja koje treba koristiti u zadnjem (:D) zadatku
Initial Title
zaglavlje bstablo_polje.h
Initial Tags
Initial Language
C++