# Posted By

elvis_popovic on 01/19/15

# Statistics

Viewed 378 times
Favorited by 0 user(s)

# Binary tree, implementation using pointers and linked lists

/ Published in: C++
`#ifndef __POKAZIVAC__#define __POKAZIVAC__#include <iostream>namespace stablo_pokazivac{  struct element{	float label;	struct element *left, *right;};	 element *LeftChildB(element *n, element *T){	return n->left;} element *RightChildB(element *n, element *T){	return n->right;} float LabelB(element *n, element *T){	return n->label;} void ChangeLabelB(float x, element *n, element *T){	n->label=x;} element *RootB(element *T){	return T;} bool CreateLeftB(float x, element *n, element *T){	if(n->left) return false;	element *novi=new element;	novi->left=NULL;	novi->right=NULL;	novi->label=x;	n->left=novi;}bool CreateRightB(float x, element *n, element *T){	if(n->right) return false;	element *novi=new element;	novi->left=NULL;	novi->right=NULL;	novi->label=x;	n->right=novi;} void DeleteB(element *n, element *T){	if(n->left) DeleteB(n->left,T);	if(n->right) DeleteB(n->right,T);	delete n;} element *ParentB(element *n, element *T){	if(T->left==n||T->right==n) return NULL;	if(T->left->left!=n&&T->left->right!=n) ParentB(n,T->left);		else return T->left;	if(T->right->left!=n&&T->right->right!=n) ParentB(n,T->right);		else return T->right;		 }; };#endif`