# Posted By

8ivana8 on 01/19/15

# Statistics

Viewed 130 times
Favorited by 0 user(s)

# binarno stablo_pretraÅ¾ivanje

/ Published in: C++
Save to your folder(s)

Implementacija binarnog stabla pretraÅ¾ivanja iz kolegija Strukture podataka.

Copy this code and paste it in your HTML
`bool ExistsLeftChild(pok_element *T){    if(T->left) 		return true;    else 		return false;} bool ExistsRightChild(pok_element *T){    if(T->right) 		return true;    else 		return false;} void InsertBS(int x, pok_element *T){    bool dalje = true;    pok_element *cvor = T; 	do{	    if(x > cvor->label){		    if(ExistsRightChild(cvor)) 				cvor = cvor->right;		    else {			    CreateRightB(x, cvor);			    dalje = false;		    }	    }	    else if(x < cvor->label){		    if(ExistsLeftChild(cvor)) 				cvor = cvor->left;		    else {			    CreateLeftB(x, cvor);			    dalje = false;		    }	    }	    else dalje = false;	}while(dalje);} void searchBT(int x, pok_element *T){    if(T->label == x){	    cout << "Element je uspjesno pronaden!" << endl << endl;	    return;    }    if(x > T->label){	    if(ExistsRightChild(T)) 			searchBT(x, T->right);	    else 			cout << "Trazeni element ne postoji!" << endl;;    }    if(x < T->label){    	if(ExistsLeftChild(T)) 			searchBT(x, T->left);    	else 			cout << "Trazeni element ne postoji!" << endl;;    }	}`