00001 #ifndef TREE_H
00002 #define TREE_H
00003 #include <string>
00004 #include <vector>
00005 #include <math.h>
00006 #include <iostream>
00007
00008 class Tree
00009 {
00010 public:
00011 Tree(){;};
00012 ~Tree(void){;};
00013
00014 void addPath(string & s){addPath(s, 0, 0);};
00015 bool evaluate(string & s){return evaluate(s, 0);};
00016
00017 void simplify(void){simplify(0);};
00018 void printTree(ostream & ost){print(ost, 0, 1);};
00019
00020 void setH(int h){arr.resize(pow(2.0, h+1)-1);};
00021 private:
00022 vector<bool> arr;
00023
00024 void addPath(string &, int, int);
00025 bool evaluate(string &, int);
00026 void simplify(int);
00027
00028 void print(ostream &, int, int);
00029 void clear(int);
00030 void copy(int , int);
00031
00032 int findCL(int i){return (2*i)+1;};
00033 int findPar(int i){return (i-1)/2;};
00034 public:
00035 Tree (const Tree & i);
00036 const Tree & operator = (const Tree &);
00037 };
00038
00039 #endif