Data Structure Using C++
Tree Data Structure
AVL (Adelson-Velskii and Landis) Tree
AVL Tree Node
class AVLNode{ private:
int info;
int height;
AVLNode* left;
AVLNode* right; public: AVLNode(); AVLNode(int i); void setInfo(int i);
int getInfo(); void setHeight(int i);
int getHeight();
void setLeft(AVLNode *l);
AVLNode* getLeft();
void setRight(AVLNode *r);
AVLNode* getRight();
int isLeaf(); }; // constructors AVLNode::AVLNode() { height=1; left=NULL; right=NULL; } AVLNode::AVLNode(int i) { info=i; height=1; left=NULL; right=NULL; } int AVLNode::getInfo() { return info; } void AVLNode::setInfo(int i) { info=i; } int AVLNode::getHeight() { return height; } void AVLNode::setHeight(int h) { height=h; } AVLNode* AVLNode::getLeft() { return left; } void AVLNode::setLeft(AVLNode *l) { left=l; } AVLNode* AVLNode::getRight() { return right; } void AVLNode::setRight(AVLNode *r) { right=r; } int AVLNode::isLeaf( ) { if(left==NULL&& right==NULL ) return 1; return 0; }
Let me know in the comment section if you have any question.
Previous Post:
Binary Search Tree In Data Structure Using C++
Comments
Post a Comment