Revision: 68436
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 18, 2015 07:53 by hcosic2
Initial Code
#include <iostream>
#define max 1000
int binT[10000];
int RootB (int binT[]) {
return 1;
}
int LabelB (int n, int binT[]) {
return binT[n];
}
int ParentB (int n, int binT[]) {
if (n==RootB(binT))return -1;
if (n%2)return (n-1)/2;
else return n/2;
}
int LeftChildB (int n, int binT[]) {
if (LabelB(n*2, binT)==-1) return -1;
return n*2;
}
int RightChildB (int n, int binT[]) {
if (LabelB(n*2+1, binT)==-1)return -1;
return n*2+1;
}
void ChangeLabelB (int x, int n, int binT[]) {
binT[n] = x;
}
bool CreateLeftB (int x, int n, int binT[]) {
if (LeftChildB(n, binT)!=-1)return false;
binT[n*2] = x;
return true;
}
bool CreateRightB (int x, int n, int binT[]) {
if (RightChildB(n, binT)!=-1)return false;
binT[n*2+1] = x;
return true;
}
void DeleteB (int n, int binT[]) {
if (LeftChildB(n, binT)!=-1)
DeleteB(LeftChildB(n, binT), binT);
if (RightChildB(n, binT)!=-1)
DeleteB(RightChildB(n, binT), binT);
binT[n]=-1;
}
void InitB (int n, int binT[]) {
for (int i=0; i<1000; i++)
binT[i] = -1;
binT[1] = n;
}
Initial URL
Initial Description
Implementacija binarnog stabla pomoću polja
Initial Title
binstablo_polje.h
Initial Tags
Initial Language
C++