This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/ex9/bintree.hpp
2021-12-03 00:09:43 +08:00

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"