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/DataStructure/Code/ex10/bintree.hpp

49 lines
978 B
C++
Raw Normal View History

2021-12-03 07:26:29 +00:00
#ifndef _bintree_hpp_
#define _bintree_hpp_
#include "binnode.hpp"
#include "list.hpp"
#include "queue.hpp"
template <class T>
class binTree
{
protected:
binNodeArray(T) _root;
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"