I am trying to implement an AVL tree and have come up with the following code.
However, when I try the following, I get an error saying that AvlNode is undeclared.
Can someone help me understand what I am doing wrong? Thanks.Code:int main() { AVL_Tree eavltree; AvlNode->element = 86;
Code:class AVL_Tree { public: struct AvlNode { int element; AvlNode *left; AvlNode *right; int height; int frequency; AvlNode( const int & theElement, AvlNode *lt, AvlNode *rt, int h = 0 ) : element( theElement ), left( lt ), right( rt ), height( h ) { } }; int insert(const int & x, AvlNode * & t ); int remove(int item); int find(int &item, int &freq); void display(); int height(AvlNode *t); int intPathLength(); int Size(); int avgeNodesVisited(); void doubleWithLeftChild(AvlNode* &k3); void doubleWithRightChild(AvlNode* &k3); void rotateWithLeftChild(AvlNode* &k2); void rotateWithRightChild( AvlNode * & k2 ); private: AvlNode *root; //pointer to root of tree int tree_height; //current height of tree int internal_path_length; //Current internal path length of tree int size; //Current number of nodes in tree int nodes_visited; //Current number of nodes visited by all finds so far int search_count; // Number of completed searches performed so far };



LinkBack URL
About LinkBacks



