51 lines
1,021 B
C++
51 lines
1,021 B
C++
|
#ifndef _bintree_hpp_
|
||
|
#define _bintree_hpp_
|
||
|
#include "binnode.hpp"
|
||
|
#include "list.hpp"
|
||
|
#include "queue.hpp"
|
||
|
template <class T>
|
||
|
class binTree
|
||
|
{
|
||
|
protected:
|
||
|
binNodeArray(T) _root;
|
||
|
List<T> plist;
|
||
|
int height;
|
||
|
|
||
|
public:
|
||
|
binNodeArray(T) root()
|
||
|
{
|
||
|
return _root;
|
||
|
}
|
||
|
binTree()
|
||
|
{
|
||
|
_root = new binNode<T>;
|
||
|
}
|
||
|
|
||
|
binNodeArray(T) addLC(binNodeArray(T) node,T data)
|
||
|
{ if(node->lc)
|
||
|
return NULL;
|
||
|
|
||
|
binNodeArray(T) temp = new binNode<T>;
|
||
|
temp->data = data;
|
||
|
node->lc = temp;
|
||
|
return temp;
|
||
|
}
|
||
|
|
||
|
binNodeArray(T) addRC(binNodeArray(T) node,T data)
|
||
|
{ if(node->rc)
|
||
|
return NULL;
|
||
|
|
||
|
binNodeArray(T) temp = new binNode<T>;
|
||
|
temp->data = data;
|
||
|
node->rc = temp;
|
||
|
return temp;
|
||
|
}
|
||
|
void trav_level()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
};
|
||
|
|
||
|
#endif
|
||
|
|
||
|
#include "bintree.h"
|