Revision: 68425
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 18, 2015 06:48 by igotepava
Initial Code
bool ExistsLeftChild(node *T){
if(T->left) return true;
else return false;
}
bool ExistsRightChild(node *T){
if(T->right) 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->right;
else {
CreateRightB(m, t);
dalje = false;
}
}
else if(m < t->label){
if(ExistsLeftChild(t)) t = t->left;
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 pronaden!\n\n";
return;
}
if(k > T->label){
if(ExistsRightChild(T)) bin_search(k, T->right);
else cout << "Trazeni element ne postoji!\n";
}
if(k < T->label){
if(ExistsLeftChild(T)) bin_search(k, T->left);
else cout << "Trazeni element ne postoji!\n";
}
}
Initial URL
Initial Description
Implementacija algoritma Binarno stablo pretraživanja.
Initial Title
binarno_stablo_pretrazivanja.h
Initial Tags
data, search
Initial Language
C++