## Posted By

kapocrnic on 01/06/11

## Versions (?)

`// binarno stablo pomocu polja, b zadatak #include <string> struct element {	std::string label;    bool used;    element() {        this->used = false;    }}; struct bt {    element elements[10000];}; typedef bt btree;typedef int node;  node ParentB(node n, btree *T) {    return n/2;}  node LeftChildB(node n, btree* T) {     if (T->elements[n*2].used)        return n*2;     else         return 0;} node RightChildB(node n, btree* T) {     if (T->elements[n*2+1].used)         return n*2+1;    else        return 0;} std::string LabelB(node n, btree* T) {     return T->elements[n].label; } void ChangeLabelB(std::string x, node n, btree* T) { T->elements[n].label = x; } node RootB(btree *T) { return 1; } bool CreateLeftB(std::string x, node n, btree* T) {    if (!LeftChildB(n, T)) {        T->elements[n*2].label = x;        T->elements[n*2].used = true;        return true;    }    else {        return false;    }} bool CreateRightB(std::string x, node n, btree *T) {    if (!RightChildB(n, T)) {        T->elements[n*2+1].label = x;        T->elements[n*2+1].used = true;        return true;    }    else {        return false;    }} void DeleteB(node n, btree *T) {    if (n*2 < 10000 && T->elements[n*2].used) {        DeleteB(n*2, T);    }    if (n*2+1 < 10000 && T->elements[n*2+1].used) {        DeleteB(n*2+1, T);    }    T->elements[n].used = false;} void InitB(std::string x, btree *T) {    T->elements[1].label = x;        T->elements[1].used = true;}`