Revision: 38619
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 6, 2011 01:23 by Sibabic
Initial Code
typedef struct element { labeltype label; struct element *left,*right; } bt; typedef struct element *node; typedef struct element *bTree; node p; node RootB(bTree T) { return T; }; node LeftChildB(node n, bTree T) { return n->left; }; node RightChildB(node n, bTree T) { return n->right; }; labeltype LabelB(node n, bTree T) { return n->label; }; int ExistsLeftChild(node n, bTree T) { if (n->left == NULL) return 0; else return 1; }; int ExistsRightChild(node n, bTree T) { if (n->right == NULL) return 0; else return 1; }; void ChangeLabelB(labeltype x, node n, bTree T) { n->label = x; }; void CreateLeftB(labeltype x, node n, bTree T) { element *tmp = new element; n->left = tmp; tmp->left = NULL; tmp->right = NULL; tmp->label = x; }; void CreateRightB(labeltype x, node n, bTree T) { element *tmp=new element; n->right = tmp; tmp->left = NULL; tmp->right = NULL; tmp->label = x; }; void SearchParentInternal(node n, bTree T) { if (LeftChildB(T,T) != NULL) if (T->left == n) p = T; else SearchParentInternal(n, T->left); if (RightChildB(T,T) != NULL) if (T->right == n) p = T; else SearchParentInternal(n, T->right); }; node ParentB(node n, bTree T) { SearchParentInternal(n,T); return p; }; void DeleteB(node n, bTree T) { node tmp; if (n != RootB(T)) { tmp = ParentB(n,T); if(tmp->left == n) tmp->left = NULL; else tmp->right = NULL; } if(n->left != NULL) DeleteB(n->left, T); if(n->right != NULL) DeleteB(n->right, T); delete n; }; void InitB(labeltype x, bTree T) { T->label = x; T->left = NULL; T->right = NULL; };
Initial URL
Initial Description
Initial Title
Zadatak 4 Implementacija binarnog stabla pomocu pokazivaca
Initial Tags
Initial Language
C++