# Posted By

isantala on 01/06/11

# Statistics

Viewed 305 times
Favorited by 0 user(s)

# Related snippets

/ Published in: C++
`struct telement{int label, root;telement *left, *right;};  typedef struct telement *tnode;typedef struct telement *ttree;  tnode ParentB (tnode node, ttree tree){tnode par;    if (LeftChildB(node, tree)){if (tree->left == node) return tree->left;par = ParentB (node, tree->left);}if (RightChildB(node, tree)){if (tree->right == node) return tree->right;par = ParentB(node, tree->right);}   return par;};  tnode LeftChildB (tnode node, ttree tree){if (node->left != NULL)return node->left;if (node->left == NULL)cout<<"Ne postoji lijevo dijete!"<<endl;};  tnode RightChildB (tnode node, ttree tree){if (node->right != NULL)return node->right;if (node->right == NULL)cout<<"Ne postoji desno dijete!"<<endl;};     int LabelB (tnode node, ttree tree){if(RootB (tree)){return node->label;}elsecout<<"ERROR"<<endl;};  void ChangeLabelB (int label, tnode node, ttree tree){if (!RootB (tree))cout << "Ne postoji cvor!" << endl;elsetree->label = label;};   tnode RootB (ttree tree){if (tree) return tree;elsecout<<"ERROR"<<endl;};  void CreateLeftB (int label, tnode node, ttree tree){tnode novi = new telement;if (LeftChildB(node, tree)){ cout<<"Vec postoji lijevo dijete!"<<endl;return;}else{novi->label = label;novi->left = NULL;novi->right = NULL;node->left = novi;   }};  void CreateRightB (int label, tnode node, ttree tree){tnode novi = new telement;if (RightChildB(node, tree)){cout<<"Vec postoji desno dijete!"<<endl;return;}else{novi->label = label;novi->left = NULL;novi->right = NULL;node->right = novi;}};   void DeleteB (tnode node, ttree tree){if (LeftChildB (node, tree)) DeleteB (node->left, tree);if (RightChildB (node, tree) ) DeleteB (node->right, tree);delete node;};       void InitB (int root, ttree tree){tnode novi = new telement;novi->root = root;novi->left = NULL;novi->right = NULL;tree = novi;};`