## Posted By

igotepava on 01/18/15

# binarno_stablo_pokazivac.h

/ Published in: C++

Implementacija binarnog stabla pomoÄ‡u pokazivaÄa.

`struct node{	int label;	node *left, *right;}; node *InitB(int x, node *T){	T = new node;	T->left = T->right = NULL;	T->label = x;	return T;} node *RootB(node *T){	return T;} node *ParentB(int n, node *T){	if(T->label == n) return NULL;	if(T->left){		if(T->left->label == n) return T;		ParentB(n, T->left);	}	if(T->right){		if(T->right->label == n) return T;		ParentB(n, T->right);	}} node *LeftChildB(node *T){	return T->left;} node *RightChildB(node *T){	return T->right;} int LabelB(node *T){	return T->label;} void ChangeLabelB(int x, node *T){	T->label = x;} void CreateLeftB(int x, node *T){	if(T->left) cout << "Cvor vec ima dijete!\n";	else{		node *novi = new node;		novi->label = x;		novi->left = novi->right = NULL;		T->left = novi;	}} void CreateRightB(int x, node *T){	if(T->right) cout << "Cvor vec ima dijete!\n";	else{		node *novi = new node;		novi->label = x;		novi->left = novi->right = NULL;		T->right = novi;	}} void DeleteB(node *n, node *T){	if(n->left != NULL) DeleteB(n->left, T);	if(n->right != NULL) DeleteB(n->right, T);	delete n;}`