Revision: 68535
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 19, 2015 08:43 by brumihali
Initial Code
bool ExistsLeftChild(node *T){
if(T->lijevo) return true;
else return false;
}
bool ExistsRightChild(node *T){
if(T->desno) return true;
else return false;
}
void insert_BS(int m, node *T){
bool dalje = true;
node *t = T;
do{
if(m > t->label){
if(ExistsRightChild(t)) t = t->desno;
else {
CreateRightB(m, t);
dalje = false;
}
}
else if(m < t->label){
if(ExistsLeftChild(t)) t = t->lijevo;
else {
CreateLeftB(m, t);
dalje = false;
}
}
else dalje = false;
}while(dalje);
}
void bin_search(int k, node *T){
if(T->label == k){
cout << "Trazeni element JE PRONADJEN!"<<endl;
return;
}
if(k > T->label){
if(ExistsRightChild(T)) bin_search(k, T->desno);
else cout << "Trazeni element NE POSTOJI!"<<endl;
}
if(k < T->label){
if(ExistsLeftChild(T)) bin_search(k, T->lijevo);
else cout << "Trazeni element NE POSTOJI!"<<endl;
}
}
Initial URL
Initial Description
Binarno stablo pretrazivanja
Initial Title
b_stablo_pretrazivanja.h
Initial Tags
Initial Language
C++